Expose ModalPopupExtender show and Hide properties in a User Control

I have a user control that contains a modalpopupextender.  How can I make the Show and Hide methods of the extender available to the page where I put the user control?
Example use in a page:
 
<uc1:CaseModal runat="server" id="cm1" />
 
Then, in my code page I want to do something like:
 
Public Sub....
 
   cm1.Show()   <---this would trigger the Show method of the Extender IN the user control.
 
End Sub
 
 
Here is a simple user control:
<asp:Panel id="modalPnl" runat="server" style="display:none;" CssClass="modalPopup">
   <asp:LinkButton id="closeCaseModal" runat="server" text="Close" />
</asp:Panel>
 
        <cc1:ModalPopupExtender 
            ID="CaseModalExtender" 
            runat="server" 
            TargetControlID="fakeButton" 
            PopupControlID="modalPnl"
            OkControlID="closeCaseModal"
            BackgroundCssClass="modalBackground" />
        <asp:LinkButton ID="fakebutton" runat="server" style="display:none;" />

Open in new window

LVL 16
Steve KrileAsked:
Who is Participating?
 
jmwheelerConnect With a Mentor Commented:
In the code behind file for you user control, add the following

Public Sub Show()
     CaseModalExtender.Show()
End Sub

Public Sub Hide()
    CaseModalExtender.Hide()
End Sub

This should add public methods to your user control which you can use from "test.aspx"
0
 
Steve KrileAuthor Commented:
And just for clarity, if my "parent" page for the user control was "test.aspx", then I would want the cm1.show() code in "test.aspx.vb"
0
 
Steve KrileAuthor Commented:
<hand slaps forehead />  

Thanks.  That's what I wanted exactly.
0
All Courses

From novice to tech pro — start learning today.