Andrea Azzola

Technology, Personal Development and Financial Independence

Using an ajax:ModalPopup Without a TargetControl

Posted on [Permalink]

The ModalPopup extender requires a control for firing up, that can be set through the TargetControlID property. However, sometimes you may want to show and hide the panel programmatically. All you need, is a fake activator like following:

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

The Extender

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

The Panel

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

The C# code

// C#
mpeInfo.Show();
mpeInfo.Hide();
Categories: AJAX

Comments

Thanks very much for this!

~David Kent