This article will show you how you can display
modalpopupextender on page load in asp.net using ajaxcontroltoolkit and C#.net.
Some of my previous articles are as follows: Dragable
ModalPopupExtender In Asp.Net Using AjaxControlToolkit, Resize
Image On The Bases Of Browser Size Using Css In Asp.Net, Add
Select text in Dropdownlist in Asp.Net OR Adding Default Select Option in the
DropDownList Using C#.Net in Asp.Net, Bind
DropdownList Using Sql Server and Datatable in Asp.Net and C#.
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.
0 comments:
Please let me know your view