Wednesday, March 21, 2012

ModalPopup - Multiple Controls open 1 popup?

Is it possible to have multiple controls open up the same modal popup window? I have content with 3 different links I need to openup the same modalpop up window.

Yes, that's achievable.

You can add client side click event handler to those links, and show the modalpopup in the handler.

For instance:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server"
</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager
</div>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:Button ID="Button2" runat="server" Text="Button"OnClientClick="$find('mpe').show(); return false;" />
<asp:Button ID="Button3" runat="server" Text="Button"OnClientClick="$find('mpe').show();return false;"/
<asp:Panel ID="Panel2" runat="server" Style="cursor: move;background-color:#DDDDDD;border:solid 1px Gray;color:Black">
<div>
<p>Choose the paragraph style you would like:</p>
</div>
</asp:Panel>

<ajaxToolkit:ModalPopupExtenderBehaviorID="mpe"ID="ModalPopupExtender1" PopupControlID="Panel2" runat="server" TargetControlID="Button1" >
</ajaxToolkit:ModalPopupExtender>
</form>
</body>
</html>

No comments:

Post a Comment