www.webdeveloper.com
Results 1 to 2 of 2

Thread: ASP.net AJAX Dropdown and Modal PopUp

Hybrid View

  1. #1
    Join Date
    Jul 2011
    Location
    Iowa
    Posts
    8

    ASP.net AJAX Dropdown and Modal PopUp

    I want to have a modal popup display when an option is chosen from a dropdown in ASP.net 4 VB. I know how to make the dropdown and I know how to make the modal popup extender, but I don't know how to tie the 2 together.
    Here is the dropdown:

    Code:
    <!-- Add to Product -->
        <asp:Label ID="lblText" runat="server" Text="Add to Product" Width="150px"></asp:Label>
        <asp:Panel ID="DropPanel" runat="server" CssClass="ContextMenuPanel" Style="display:none; visibility:hidden; margin-left:2px;">  
            <asp:LinkButton ID="Company" runat="server" Text="Company" CssClass="ContextMenuItem" OnClick="OnSelect"></asp:LinkButton>
        <asp:DropDownExtender ID="DropDownExtender1" runat="server" TargetControlID="lblText" DropDownControlID="DropPanel">
        </asp:DropDownExtender>
    And the modalpopupextender to add the company to the database

    Code:
     <!-- Add a Company -->
    <asp:LinkButton ID="LinkButton1" runat="server">Company</asp:LinkButton>
        <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display:none">
            <asp:CheckBoxList ID="cbxAddCompany" runat="server" DataSourceID="dsNewCompanies" DataTextField="CompanyName" DataValueField="CompanyID">
            </asp:CheckBoxList>
    <asp:Button ID="SubmitCompanies" runat="server" Text="Submit" /><asp:Button ID="CancelSubmitCompanies"
        runat="server" Text="Cancel" />
        </asp:Panel>
        <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1" PopupControlID="Panel1" BackgroundCssClass="modalBackground" DropShadow="true" OkControlID="SubmitCompanies" CancelControlID="CancelSubmitCompanies">
        </asp:ModalPopupExtender>
    VB:

    Code:
     Protected Sub SubmitCompanies_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitCompanies.Click
            Dim SqlConnection As New SqlConnection("Server=off-db1;uid=productsDB_admin;pwd=@cc3ssproductsdb;database=Products")
            For Each company As ListItem In cbxAddCompany.Items
                If company.Selected Then
                    SqlConnection.Open()
                    Dim sqlAddCompany As String = "INSERT INTO CompanyLink (ProductID, CompanyID) VALUES (" & ProductID.Value & ", " & company.Value & ")"
                    Dim sqlCommand As New SqlCommand(sqlAddCompany, SqlConnection)
                    sqlCommand.ExecuteNonQuery()
                    SqlConnection.Close()
                End If
            Next
            Response.Redirect(Request.RawUrl)
        End Sub

  2. #2
    Join Date
    Jul 2011
    Location
    Iowa
    Posts
    8
    i got this answer from another forum
    hi,

    you can do that. based on dropdown selection if you want to show the different modalpopup you can show like below in dropdown_selectedindexchanged event

    ModalPopupExtender1.Show();

    but dont set TargetControlID as button for ModalPopupExtender instead of button set label and set label.text="";

    based on if condition you can display the respective ModalPopupExtender in dropdown_selectedindexchanged event

    refer : http://stackoverflow.com/questions/1...ent-not-firing

    http://stackoverflow.com/questions/2...nt-from-firing

    http://www.codeproject.com/KB/ajax/A...lInAction.aspx

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles