darylbewise
Programmer
Hello all,
Im trying to get an update panel to update while I am executin a large process. If I can output to the screen, I will know exactly where the process is up to. For example:
//.aspx
//.aspx.cs
Im the above example, when Button1 is clicked, the update panel is updated without an actual page refresh. However, when the button is clicked I do not see label1 altering value from "TEXT1" to "TEXT2" to "TEXT3", all that I see is "TEXT3" after a short pause (due to the Thread.Sleep commands.).
Any ideals how I could go about updating the text in Label1 while the code in Button1_Click is still exectuting?
I have even tried to add in "UpdatePanel1.Update();" after setting each Label.Text value, however same happens.
Any help would be much appreciated
Im trying to get an update panel to update while I am executin a large process. If I can output to the screen, I will know exactly where the process is up to. For example:
//.aspx
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="START" />
</form>
</body>
</html>
//.aspx.cs
Code:
using System;
using System.Threading;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Thread.Sleep(1000);
Label1.Text = "TEXT1";
Thread.Sleep(1000);
Label1.Text = "TEXT2";
Thread.Sleep(1000);
Label1.Text = "TEXT3";
}
}
Im the above example, when Button1 is clicked, the update panel is updated without an actual page refresh. However, when the button is clicked I do not see label1 altering value from "TEXT1" to "TEXT2" to "TEXT3", all that I see is "TEXT3" after a short pause (due to the Thread.Sleep commands.).
Any ideals how I could go about updating the text in Label1 while the code in Button1_Click is still exectuting?
I have even tried to add in "UpdatePanel1.Update();" after setting each Label.Text value, however same happens.
Any help would be much appreciated