Follow by Email

Tuesday, May 21, 2013

Ajax ModalPopupExtender Demo in | Ajax ModalPopupExtender Example

Hello In this post i will be demonstrating on how to use Ajax ModalPopupExtender control in


1. On linkbutton click I will be showing the Ajax modal popup Screen. On the modal popup screen i will bind a gridview with some sample Data.

2. Below is the code


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ModalPopup.aspx.cs" Inherits="Mailjavascript" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <style type="text/css">
            background-color: Gray;
            filter: alpha(opacity=50);
            opacity: 0.7;
    <form runat="server">
    <ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    <asp:LinkButton ID="LinkButton1" runat="server">Click Me</asp:LinkButton>

    <asp:Panel ID="Panel1" runat="server" BorderColor="Black" BackColor="White" Height="300px"
        Width="800px" HorizontalAlign="Center">
        <asp:GridView ID="GridView1" runat="server">
        <br />
        <br />
        <asp:Button ID="Ok" runat="server" Text="submit" OnClick="Button2_Click" />
        <asp:Button ID="can" runat="server" Text="cancel" />

    <ajax:ModalPopupExtender ID="MPE" runat="server" TargetControlID="LinkButton1" PopupControlID="Panel1"
        BackgroundCssClass="modalBackground" CancelControlID="can">


using System;
using System.Web;
using System.Web.UI;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

public partial class Mailjavascript : System.Web.UI.Page
    string conStr = ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ConnectionString.ToString();
    protected void Page_Load(object sender, EventArgs e)
        SqlConnection s1 = new SqlConnection(conStr);

        string queryString = "SELECT * FROM employee";
        SqlDataAdapter adapter = new SqlDataAdapter(queryString, s1);

        DataSet employee = new DataSet();
        adapter.Fill(employee, "employee");


        GridView1.DataSource = employee.Tables[0];

    protected void Button2_Click(object sender, EventArgs e)

3. Result:

1. Click on linkButton

2. ModalPopExtender Screen