ModalPopupExtender from Server Side Code in c#

£可爱£侵袭症+ 提交于 2020-01-24 03:22:05

问题


I had a nightmare getting this going.

Adding the ModalPopupExtender to a form is easy, you drop it on and tell it the two required controls parameters

PopupControlID="MyModalPanel"
TargetControlID="ButtonToLoadIt"

And it just works fine, but is triggered by a client side click of the Target Control.

If you want to do some server side code behind??? how to do it ?


回答1:


The example code is shown below:

HTML CODE:

<!-- 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# Code

WarningModal.Show();
lblWarning.Text = "This is a popup warning";

for ref s

http://www.codeproject.com/Tips/215040/ModalPopupExtender-from-Server-Side-Code



来源:https://stackoverflow.com/questions/18299028/modalpopupextender-from-server-side-code-in-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!