Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ModalPopupExtender from Server Side Code in c#

Tags:

ajax

c#-4.0

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 ?

like image 879
user2693849 Avatar asked Aug 18 '13 12:08

user2693849


1 Answers

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

like image 159
Ryder Avatar answered Dec 31 '22 19:12

Ryder