I have a User Control called: Share.ascx
I have a page called: News.aspx
In News.aspx I created a ModalPopupExtender, then I addeda Panel and inside the Panel I added the User Control: Share.ascx so that when the Popup Extender is called the Panel with the User Control is displayed.
The problem:
I can only HIDE the ModalPopupExtender from News.aspx because ModalPopupExtender is defined there but I need to call the HIDE funciton of ModalPopupExtender from the User Control: Share.ascx.cs
How do I do that?
Thank you.
----------------------News.aspx-------------------------
<asp:Content ID="Content1" runat="server">
<asp:LinkButton ID="lbtnShare" runat="server" Text='Share Link' />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="lbtnShare" PopupControlID="Panel1"
Drag="true" RepositionMode=RepositionOnWindowResizeAndScroll
BackgroundCssClass="modalBackground" >
</asp:ModalPopupExtender>
<asp:panel id="Panel1" runat="server" style="display:none">
<uc2:ShareLink ID="ShareLink" runat="server" />
</asp:panel>
</asp:Content>
----------------------Share.ascx-------------------------
<asp:UpdatePanel ID="upSET" runat="server">
<ContentTemplate>
<asp:Button ID="btnCancel" Text="Cancel" runat="server" OnClick="btnCancel_Click" CausesValidation="false" />
</ContentTemplate>
</asp:UpdatePanel>
The files are too long so I omitted a lot of it and only put the important parts.
Share.ascx has a Cancel button, in that button I want to call the Hide() function of ModalPopupExtender1 that is located in News.aspx.
From the usercontrol code behind try to find your ModalPopupExtender
var popup = Parent.FindControl("ModalPopupExtender1") as ModalPopupExtender;
and then call the Hide() method
popup.Hide();
You can reference the Ok and cancel controls from the parent form in your ModalPopupExtender by appending the ID of your Cancel button to the ID of the User Control. I use the following code:
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" Enabled="True"
TargetControlID="Button1" PopupControlID="UpdatePanel1"
OkControlID="OpenRec1_btnOK"
CancelControlID="OpenRec1_btnCancel">
</asp:ModalPopupExtender>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<uc1:OpenRec runat="server" id="OpenRec1" />
</ContentTemplate>
</asp:UpdatePanel>
The Ok and Cancel buttons in my User Control are named btnOK and btnCancel.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.