我做了一场噩梦。
将 ModalPopupExtender 添加到表单很容易,您将其放入并告诉它两个必需的控件参数
PopupControlID="MyModalPanel"
TargetControlID="ButtonToLoadIt"
它工作正常,但由目标控件的客户端单击触发。
如果你想在后面做一些服务器端代码???怎么做 ?
示例代码如下所示:
HTML 代码:
<!-- Hidden Field -->
<asp:HiddenField ID="hidForModel" runat="server" />
<asp:ModalPopupExtender
ID="WarningModal"
TargetControlID="hidForModel"
runat="server"
CancelControlID="btnWarning"
DropShadow="true"
PopupControlID="pnlIssues" >
</asp:ModalPopupExtender>
<!-- Panel -->
<asp:Panel ID="pnlIssues" runat="server"
BorderColor="Black" BorderStyle="Outset"
BorderWidth="2" BackColor="Wheat" Width="400px" Height="106px">
<center>
<h2 class="style2">
Information</h2>
<p>
<h3> <asp:Label ID="lblWarning"
runat="server"> </asp:Label></h3>
</p>
<!-- Label in the Panel to turn off the popup -->
<asp:ImageButton ID="btnWarning" runat="server"
ImageUrl="~/images/buttons/update.png" />
</center>
</asp:Panel>
C# 代码
WarningModal.Show();
lblWarning.Text = "This is a popup warning";
对于参考
http://www.codeproject.com/Tips/215040/ModalPopupExtender-from-Server-Side-Code