Step 1: - Right Click on Project Root folder => Click on Manage NuGet Packages… => Search Ajax in search box and Select AjaxControlToolkit from list =>
Click on Install button
Step 2: - Design Page
Code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxUpdateProgress.aspx.cs" Inherits="AjaxControls.AjaxUpdateProgress" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Load Data" OnClick="Button1_Click" />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<br />
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
<span style="border-width: 0px; position: fixed; padding: 20px; background-color: #FFFFFF; font-size: 30px; left: 40%; top: 40%; border-radius: 50px;">Loading ...</span>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</div>
</form>
</body>
</html>
Step 3: - Code behind
Page Code
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace AjaxControls
{
public partial class AjaxUpdateProgress : System.Web.UI.Page
{
protected void
Page_Load(object
sender, EventArgs e)
{
}
protected void
Button1_Click(object
sender, EventArgs e)
{
//Sleep
the thread to see loading progress
Thread.Sleep(10000);
GridView1.DataSource = BindData();
GridView1.DataBind();
}
protected DataTable BindData()
{
DataTable dt = new DataTable();
DataRow dr = null;
dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
dt.Columns.Add(new DataColumn("Column1", typeof(string)));
dt.Columns.Add(new DataColumn("Column2", typeof(string)));
dt.Columns.Add(new DataColumn("Column3", typeof(string)));
int totalRow = 9;
for (int
i = 0; i < totalRow; i++)
{
dr = dt.NewRow();
dr["RowNumber"] = i +
1;
dr["Column1"] = "Row" + i;
dr["Column2"] = "Row" + i;
dr["Column3"] = "Row" + i;
dt.Rows.Add(dr);
}
return dt;
}
}
}
Step 4: - Output
Note:- Instead of Loading text you can use loader.gif image.
To download loader.gif
Right Click and Save
It works well. Thanks
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete