Click here to Skip to main content
14,921,745 members
Articles / Web Development / ASP.NET
Posted 22 Jun 2011

Tagged as


1 bookmarked

ModalPopupExtender from Server Side Code

Rate me:
Please Sign up or sign in to vote.
4.92/5 (17 votes)
25 Jun 2011CPOL
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:


<!-- Hidden Field -->
<asp:HiddenField ID="hidForModel" runat="server" />

PopupControlID="pnlIssues" >

<!-- Panel -->
<asp:Panel ID="pnlIssues" runat="server"  
BorderColor="Black" BorderStyle="Outset"  
BorderWidth="2" BackColor="Wheat" Width="400px"  Height="106px">
       <h2 class="style2">

         <h3> <asp:Label ID="lblWarning" 
runat="server"> </asp:Label></h3>

 <!-- Label in the Panel to turn off the popup -->
 <asp:ImageButton ID="btnWarning" runat="server"
                ImageUrl="~/images/buttons/update.png" />


C# Code

lblWarning.Text = "This is a popup warning";

Enjoy and remember to vote.


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


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
MCAD Passed
MCP C# ASP.NET Web Applications
MCP SQL Server 2000
HND Computing
OND / HNC Electrical Engineering,

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
professionalDrABELL27-Jun-11 4:14 
GeneralHi Frank, Thanks for sharing this very practical solution. I... Pin
DrABELL23-Jun-11 2:57
professionalDrABELL23-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
professionalDrABELL23-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.