Some time we have a method which takes a bit more time to execution.Due to this time consumption user get impatient One of Ajax control solved this problem which is ASP.NET AJAX Update Progress Control. ASP.NET AJAX Update Progress Control provides status information about page updates.
Here I am going to explain how to use ASP.NET AJAX Updated Progress Control in a web page.
Firstly we need a animated GIF.I am using the following image.
In case of Visual studio 2005 install AjaxControlToolkit and in case of Visual studio 2010 add AjaxControlToolkit.dll in the project.
Firstly we have to add scriptmanger inside the form tag.
<asp:ScriptManager ID="ScriptManager1" runat="server" />
And Use updatePanel because we need partial update of page.
And drag updateProgress from toolbox to the page.
After that page will be look like this:
Code:
<body >
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div >
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Width="134px"></asp:Label><br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<img src="ajax-loader.gif" />
Updating Page ......
</ProgressTemplate>
</asp:UpdateProgress>
</form>
</body>
And on the button Click event Add the following code:
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
Label1.Text = DateTime.Now.ToString();
}
Run the project and click on the button which is on the Default page.The page will be look like this:
Happy Programming...:)
Here I am going to explain how to use ASP.NET AJAX Updated Progress Control in a web page.
Firstly we need a animated GIF.I am using the following image.
In case of Visual studio 2005 install AjaxControlToolkit and in case of Visual studio 2010 add AjaxControlToolkit.dll in the project.
Firstly we have to add scriptmanger inside the form tag.
<asp:ScriptManager ID="ScriptManager1" runat="server" />
And Use updatePanel because we need partial update of page.
And drag updateProgress from toolbox to the page.
After that page will be look like this:
Code:
<body >
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div >
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Width="134px"></asp:Label><br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<img src="ajax-loader.gif" />
Updating Page ......
</ProgressTemplate>
</asp:UpdateProgress>
</form>
</body>
And on the button Click event Add the following code:
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
Label1.Text = DateTime.Now.ToString();
}
Run the project and click on the button which is on the Default page.The page will be look like this:
Happy Programming...:)
Comments
Post a Comment