Click here to Skip to main content
12,406,124 members (70,702 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

61.2K views
1 bookmarked
Posted

ModalPopupExtender from Server Side Code

, 25 Jun 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
Enabling ModalPopupExtender from ServerSide Code in the Ajax Control Kit
Getting the ModalPopupExtender to work from Server Side Code is quite simple once you know how. The control can be triggered via code with the Show method, but you need a dummy client control for the TargetControlID in the ModalPopupExtender.

I've used an ASP.NET HiddenField which will render correctly without using style sheet magic to hide it from the form.

The complete 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";
Enjoy and remember to vote.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Frank Kerrigan
Software Developer (Senior)
United Kingdom United Kingdom
Frank Kerrigan

Currently developing Insurance systems with SQL Server, ASP.NET, C#, ADO for a company in Glasgow Scotland. Very keen on OOP and NUNIT testing. Been in IT forever (20 years) in mix of development and supporting applications / servers. Worked for companies big and small and enjoyed both.

Developed in (newest first) : C#, Progress 4GL, ASP.NET, SQL TSQL, HTML, VB.NET, ASP, VB, VBscript, JavaScript, Oracle PSQL, perl, Access v1-2000, sybase/informi, Pic Controllers, 6502 (ask your dad).

Msc .Net Development Evenings www.gcu.ac.uk
MCAD Passed
MCP C# ASP.NET Web Applications
MCP SQL Server 2000
HND Computing
OND / HNC Electrical Engineering,

You may also be interested in...

Comments and Discussions

 
GeneralMy vote of 5 Pin
MrCodeIt11-Aug-15 9:14
memberMrCodeIt11-Aug-15 9:14 
QuestionAwesome solutions Pin
MrCodeIt11-Aug-15 9:21
memberMrCodeIt11-Aug-15 9:21 
QuestionVery interesting! Pin
robertd9039-Dec-14 15:48
memberrobertd9039-Dec-14 15:48 
QuestionGood Article Pin
Sraven Kande22-Jul-14 7:54
memberSraven Kande22-Jul-14 7:54 
Questionquery Pin
vidyaraj147-Nov-13 1:32
membervidyaraj147-Nov-13 1:32 
QuestionModalPopup show call from code behind page Pin
swethavor17-Feb-13 5:48
memberswethavor17-Feb-13 5:48 
GeneralMy vote of 5 Pin
Bilal Fazlani22-May-12 21:27
memberBilal Fazlani22-May-12 21:27 
Generalvery good trick! Pin
Bilal Fazlani22-May-12 21:26
memberBilal Fazlani22-May-12 21:26 
GeneralRe: I agree, Frank! My best, Alex Pin
DrABELL27-Jun-11 4:14
memberDrABELL27-Jun-11 4:14 
GeneralHi Frank, Thanks for sharing this very practical solution. I... Pin
DrABELL23-Jun-11 2:57
memberDrABELL23-Jun-11 2:57 
GeneralRe: Cheers for the feedback, I'll leave my tip as or it or it wi... Pin
Frank Kerrigan27-Jun-11 3:38
memberFrank Kerrigan27-Jun-11 3:38 
GeneralReason for my vote of 5 Very practical solution! Pin
DrABELL23-Jun-11 2:52
memberDrABELL23-Jun-11 2:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160726.1 | Last Updated 25 Jun 2011
Article Copyright 2011 by Frank Kerrigan
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid