Tuesday, 16 December 2014

Display ModalPopupExtender on Page Load In Asp.Net Using AjaxControlToolkit, C#.Net

12/16/2014 - By Pranav Singh 0



This article will show you how you can display modalpopupextender on page load in asp.net using ajaxcontroltoolkit and C#.net.



So for this article first we will create a new asp.net application and add the below code into the .asp page.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="WebApplication1.WebForm4" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Display ModalPopupExtender on Page Load In Asp.Net Using AjaxControlToolkit, C#.Net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="hidVal"
            PopupControlID="divMessage" CancelControlID="btnClose" PopupDragHandleControlID="divheader">
        </asp:ModalPopupExtender>
        <h3>ModalPopupExtender on Page Load</h3>
        <input type="hidden" id="hidVal" runat="server" />
        <div runat="server" style="width: 300px;" id="divMessage">
            <table width="300px" border="1">
                <tr>
                    <td>
                        <div style="background-color: Gray; height: 20px; font-weight: bold;" id="divheader">
                            Message</div>
                        <div style="height: 100px;">
                            This is a test message on page load.</div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Button ID="btnClose" runat="server" Text="Close" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>
</body>
</html>
 
In above code I have take a hidden filed to assign the target field. Now for opening the ModalPopupExtender on page add the below code into the page load.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm4 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ModalPopupExtender1.Show();
        }
    }
}

Now we in above code we have just show the ModalPopupExtender. Now we  have done run the application and check the output.

 

About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top