Sunday, October 28, 2007

Ajax UpdatePanel (8) UpdateProgress

UpdateProgress:

<asp:UpdateProgress ID="UpdateProgress1" runat="server" DynamicLayout="false" AssociatedUpdatePanelID="UpdatePanel1">

<ProgressTemplate>

DynamicLayout = false

</ProgressTemplate>

</asp:UpdateProgress>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>

<%= DateTime.Now %>

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

</ContentTemplate>

</asp:UpdatePanel>

<asp:UpdatePanel ID="UpdatePanel2" runat="server">

<ContentTemplate>

<%= DateTime.Now %>

<asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button1_Click" />

</ContentTemplate>

</asp:UpdatePanel>

<asp:UpdateProgress ID="UpdateProgress2" runat="server" DynamicLayout="true" DisplayAfter="3000">

<ProgressTemplate>

DynamicLayout = true

</ProgressTemplate>

</asp:UpdateProgress>



using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Threading;

public partial class Demo3_1_UpdateProgress : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void Button1_Click(object sender, EventArgs e)

{

Thread.Sleep(5000);

}

}

In this code, when you click Button1, the UpdateProgress1 will display straight away, the UpdateProgress2 will display after 3 seconds. When you clikc Button2, only UpdateProgress2 will display after 3 seconds.

blog comments powered by Disqus