Using an ajax:ModalPopup without a TargetControl

Posted by Andrea on 2007-09-25 09:41
The ModalPopup extender requires a control for firing up, this can be set through the TargetControlID property.
However, sometimes we need to Show and Hide the Panel programmatically.
All that you need, is a fake activator like following:

<div id="divFakeActivator" runat="server" style="display: none" />

This is my Extender:

<ajax:ModalPopupExtender ID="mpeInfo" runat="server" TargetControlID=" divFakeActivator " PopupControlID="pnlInfo" CancelControlID="bttInfoClose" />

This is my Panel:

<asp:Panel ID="pnlInfo" runat="server">
Hello World!!!
</
asp:Panel>

And then…

// C#
mpeInfo.Show();
mpeInfo.Hide();

Comments

David Kent commented
Gravatar
Thanks very much for this!