I am opening a modal popup. The popup calls in a User Control. I am looking how to add a Close Window link or button to on the UserControl that will close the popup window.
In the parent (aspx page) there is a onclick command that control the Image Link to close the window, but I would also like to be able to have another link or button that will close the window also.
Is there a way to call onclick event in the parent page code behind? Or, how would I be able to close the modal popup form the user control?
Thanks in advance,
My code below:
ASPX PAGE (code that executes the button click to open popup):
you can add a image button and on the onlick event of the button pass the event to the parent page using delegate, and from there you can close call the hide function of the modal popup.
PS: use the update panel wisely.
Marked as answer by BU XI - MSFT on May 28, 2012 02:48 AM
c2w
Member
4 Points
29 Posts
Modal Popup - Close link
May 22, 2012 06:29 AM|LINK
I am opening a modal popup. The popup calls in a User Control. I am looking how to add a Close Window link or button to on the UserControl that will close the popup window.
In the parent (aspx page) there is a onclick command that control the Image Link to close the window, but I would also like to be able to have another link or button that will close the window also.
Is there a way to call onclick event in the parent page code behind? Or, how would I be able to close the modal popup form the user control?
Thanks in advance,
My code below:
ASPX PAGE (code that executes the button click to open popup):
<asp:Button ID="ShowDeleteMatchPopUp_BTN" runat="server" OnCommand="ShowDeleteMatchPopUp_Click" text="delete"/> <asp:UpdatePanel ID="DeleteMatch" runat="server" UpdateMode="Always" EnableViewState="true"> <Triggers> <asp:AsyncPostBackTrigger ControlID="ShowDeleteMatchPopUp_BTN" EventName="Click" /> </Triggers> <ContentTemplate> <asp:Panel ID="panelOverlay_DeleteMatch" runat="server" class="Overlay" Visible="false"> </asp:Panel> <asp:Panel ID="panelPopUpPanel_DeleteMatch" runat="server" class="PopUpDeletePanel" Visible="false"> <asp:Panel ID="panelPopUpTitle_DeleteMatch" runat="server" Style="width: 100%; text-align: right;"> <div style="overflow: hidden"> <div style="font-size: 16px; font-weight: bold; width: 50%; float: left; text-align: left;"> Delete Match</div> </div> <div style="width: 46px; float: right; margin: -45px -25px 0 0;"> <asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="~/Images/icons/buttons/closePopUp.png" OnClick="cmdCloseDeleteMatchPopUp_Click" /> </div> </asp:Panel> <div style="clear: both; margin: 5px 0 0 0;"> <uc3:matchDelete ID="matchDelete1" runat="server" /> </div> </asp:Panel> </ContentTemplate> </asp:UpdatePanel>CS page:
protected void ShowDeleteMatchPopUp_Click(object sender, CommandEventArgs ew) { matchDelete1.MatchIDTextValue = ew.CommandArgument.ToString(); showPopUp_DeleteMatch(true); } private void showPopUp_DeleteMatch(bool b) { panelOverlay_DeleteMatch.Visible = b; panelPopUpPanel_DeleteMatch.Visible = b; } protected void cmdCloseDeleteMatchPopUp_Click(object sender, System.Web.UI.ImageClickEventArgs e) { showPopUp_DeleteMatch(false); }mike07
Member
57 Points
18 Posts
Re: Modal Popup - Close link
May 22, 2012 06:42 AM|LINK
you can add a image button and on the onlick event of the button pass the event to the parent page using delegate, and from there you can close call the hide function of the modal popup.
PS: use the update panel wisely.