How to use Model Popup Extender

The following code shows how to use Model Popup Extender

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns="">
<head runat="server">
<title>Untitled Page</title>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<%-- <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>--%>
<asp:Button runat="server" ID="hiddenTargetControlForModalPopup" Style="display: none" />
<asp:LinkButton runat="server" ID="showModalPopupServerOperatorButton" Text="show"
OnClick="showModalPopupServerOperatorButton_Click" />
<ajaxtoolkit:ModalPopupExtender runat="server" ID="programmaticModalPopup" BehaviorID="programmaticModalPopupBehavior"
TargetControlID="hiddenTargetControlForModalPopup" PopupControlID="programmaticPopup"
BackgroundCssClass="modalBackground" DropShadow="True" RepositionMode="RepositionOnWindowScroll">
<asp:Panel runat="server" CssClass="modalPopup" ID="programmaticPopup" Style="display: none;
width: 350px; padding: 10px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
<%-- <asp:LinkButton runat="server" ID="hideModalPopupViaServer" Text="close" OnClick="hideModalPopupViaServer_Click" />--%>

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default1 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

protected void showModalPopupServerOperatorButton_Click(object sender, EventArgs e)
TextBox1.Text = TextBox2.Text;
protected void hideModalPopupViaServer_Click(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
Label1.Text = TextBox1.Text;



Author: Kapil Dhawan17 Jun 2008 Member Level: Gold   Points : 2

Nice piece of code
Thanks for sharing your knowledge with us.
I hope to see more good code from your side
This code is going to help lots of guys.
Ton Thanks to you

Guest Author: B Kumar23 Feb 2013

Nice Example ...
Makes webpages more enhance.

Guest Author: Andrew W12 Aug 2013

This piece of code got me out of trouble. I have a gridview embedded in modal popup filtered by text boxes & pressing the button to call gridview was closing popup
Thank you v much

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: