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