Updated on Kisan Patel
This tutorial will explain you how to use UpdateProgress control for single and multiple UpdatePanel control in ASP.NET.
Sometimes working with UpdatePanel control, you need to show the progress status of the requested data to refresh the content of the UpdatePanel control. This task is accomplished with the help of the UpdateProgress control. Lets take one example to understand how UpdateProgrss control can be used with UpdatePanel control.
Here, we will use ScriptManager control, UpdateProgress control, UpdatePanel control, and two Label control.
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="UpdateProgressDemo.Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>UpdateProgress control demo</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <asp:UpdateProgress ID="UpdateProgress1" runat="server"> <ProgressTemplate> <p>Progressing...</p> </ProgressTemplate> </asp:UpdateProgress> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <h2>UpdatePanel 1 with UpdateProgress control Demo</h2> <asp:Label ID="Label1" runat="server" Text="Update Progress Demo"></asp:Label> <asp:Button ID="Button1" runat="server" Text="Progress" OnClick="Button1_Click" /> </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <h2>UpdatePanel 2 with UpdateProgress control Demo</h2> <asp:Label ID="Label2" runat="server" Text="Update Progress Demo"></asp:Label> <asp:Button ID="Button2" runat="server" Text="Progress" OnClick="Button2_Click" /> </ContentTemplate> </asp:UpdatePanel> </form> </body> </html>
Default.aspx.cs
using System; namespace UpdateProgressDemo { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(2000); Label1.Text = "Update Panel 1 Updated At " + DateTime.Now.ToShortDateString(); } protected void Button2_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(2000); Label1.Text = "Update Panel 2 Updated At " + DateTime.Now.ToShortDateString(); } } }
You could use AssociatedUpdatePanelID
property of UpdateProgress control to associate particular UpdatePanel control like below:
<form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel2"> <ProgressTemplate> <p>Progressing...</p> </ProgressTemplate> </asp:UpdateProgress> ..... </form> </body> </html>
Demo