L
Larry R
I am trying to set a panel (that holds a progress image) to be visible
when a long running process is happening. Sounds simple, right
What
happens is the panel never becomes visible. The load and prerender
events occur, but it is never displayed.
In the super simple example, I use the "hide panel", then click the "Do
Process". The next thing I see is the "done". Why won't the panel
display?
Here is the code:
--------------------------------------
ASPX
--------------------------------------
<%@ Page Language="VB" Async="true" AutoEventWireup="false"
CodeFile="TestBGWorker.aspx.vb" Inherits="Tasks_TestBGWorker" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnHide" runat="server" Text="Hide Panel" /><br
/>
<asp:Button ID="Button1" runat="server" Text="Do Process" />
<asp
anel ID="Panel1" runat="server" Height="50px"
Width="125px">
<asp:Label ID="Label1" runat="server"
Text="Processing......"></asp:Label></asp
anel>
</div>
<asp:Label ID="Label2" runat="server"></asp:Label>
</form>
</body>
</html>
---------------------------------------------
Code Behind
---------------------------------------------
Imports System.Threading
Imports System.ComponentModel
Partial Class Tasks_TestBGWorker
Inherits System.Web.UI.Page
Private WithEvents worker As BackgroundWorker
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
worker = New BackgroundWorker()
worker.WorkerReportsProgress = True
Panel1.Visible = True
worker.RunWorkerAsync()
End Sub
Protected Sub worker_DoWork(ByVal sender As Object, ByVal e As
System.ComponentModel.DoWorkEventArgs) Handles worker.DoWork
System.Threading.Thread.Sleep(2000)
worker.ReportProgress(10)
System.Threading.Thread.Sleep(5000)
End Sub
Protected Sub worker_ProgressChanged(ByVal sender As Object, ByVal
e As System.ComponentModel.ProgressChangedEventArgs) Handles
worker.ProgressChanged
Panel1.Visible = True
Label1.Text = e.ProgressPercentage.ToString()
End Sub
Protected Sub worker_RunWorkerCompleted(ByVal sender As Object,
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles
worker.RunWorkerCompleted
Panel1.Visible = False
Label2.Text = "done...."""
End Sub
Protected Sub btnHide_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnHide.Click
Panel1.Visible = False
End Sub
End Class
when a long running process is happening. Sounds simple, right
happens is the panel never becomes visible. The load and prerender
events occur, but it is never displayed.
In the super simple example, I use the "hide panel", then click the "Do
Process". The next thing I see is the "done". Why won't the panel
display?
Here is the code:
--------------------------------------
ASPX
--------------------------------------
<%@ Page Language="VB" Async="true" AutoEventWireup="false"
CodeFile="TestBGWorker.aspx.vb" Inherits="Tasks_TestBGWorker" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnHide" runat="server" Text="Hide Panel" /><br
/>
<asp:Button ID="Button1" runat="server" Text="Do Process" />
<asp
Width="125px">
<asp:Label ID="Label1" runat="server"
Text="Processing......"></asp:Label></asp
</div>
<asp:Label ID="Label2" runat="server"></asp:Label>
</form>
</body>
</html>
---------------------------------------------
Code Behind
---------------------------------------------
Imports System.Threading
Imports System.ComponentModel
Partial Class Tasks_TestBGWorker
Inherits System.Web.UI.Page
Private WithEvents worker As BackgroundWorker
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
worker = New BackgroundWorker()
worker.WorkerReportsProgress = True
Panel1.Visible = True
worker.RunWorkerAsync()
End Sub
Protected Sub worker_DoWork(ByVal sender As Object, ByVal e As
System.ComponentModel.DoWorkEventArgs) Handles worker.DoWork
System.Threading.Thread.Sleep(2000)
worker.ReportProgress(10)
System.Threading.Thread.Sleep(5000)
End Sub
Protected Sub worker_ProgressChanged(ByVal sender As Object, ByVal
e As System.ComponentModel.ProgressChangedEventArgs) Handles
worker.ProgressChanged
Panel1.Visible = True
Label1.Text = e.ProgressPercentage.ToString()
End Sub
Protected Sub worker_RunWorkerCompleted(ByVal sender As Object,
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles
worker.RunWorkerCompleted
Panel1.Visible = False
Label2.Text = "done...."""
End Sub
Protected Sub btnHide_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnHide.Click
Panel1.Visible = False
End Sub
End Class