We help IT Professionals succeed at work.

Expose ModalPopupExtender show and Hide properties in a User Control

Steve Krile
Steve Krile asked
on
Medium Priority
1,180 Views
Last Modified: 2013-11-07
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

Comment
Watch Question

Author

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"
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"

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
<hand slaps forehead />  

Thanks.  That's what I wanted exactly.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.