Please Wait

  • Thread starter Thread starter mw
  • Start date Start date
M

mw

I'm writing an application that's going to do alot of processing while the
user is waiting, (imagine sitting and waiting while the server/background
processing is occurring). What's the best way to entertain the user (e.g.
show them something's happening - e.g. animated gif progress bar or
something) and then automatically show the "done" page when the processing
is finished.

Thanks!
 
Maybe you want to look into delegating that task to another process, and the
page refreshes itself every few seconds to show the end user a progress bar
or something like that. Long running processes that are oltp based are
always clumsy in Asp.net :-/
That'll keep them busy, but If you really wanna entertain them, maybe you
could show them a blonde joke at every page refresh (just kidding).

- Sahil Malik
You can reach me thru my blog http://www.dotnetjunkies.com/weblog/sahilmalik
 
Hi

How does Duncan's code help in a Web Forms situation? Someone clicks submit
on a form or something, the asp does the code behind for the next page (which
does whatever they submitted it to do). How does the progress bar fit in?

dan
 
My apologies. The article I referenced was not the one I intended. (So many
ideas...) I have used the included aspx page to display a progress bar while
another aspx page is performing a long-running process to collect report
data. This page is started by calling it with the name of the long-running
page in the QueryString.



<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="PleaseWait.aspx.vb" Inherits="BRS_Vouchers.PleaseWait"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>PleaseWait</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<META http-equiv=Refresh
content='3; URL=<% =(Request.QueryString("TargetPage") & "?x=" &
DateTime.Now.ToString("ddMMMyyyyHmmss")) %>'>
<SCRIPT language="javascript">
var i = 0;
function ProgressBar(secondsForWaiting, minutesForWaiting)
{
if (secondsForWaiting.valueOf() > 0)
{
d3.innerText = "This process can take up to "
+ secondsForWaiting + " seconds...";
timedIterations(secondsForWaiting);
}
else
{
if (minutesForWaiting.valueOf() > 0)
{
d3.innerText =
"This process can take up to "
+ minutesForWaiting + " minutes...";
timedIterations(minutesForWaiting * 60);
}
}
}

function timedIterations(secondsForIterating)
{
incrementalWidth = 800 / secondsForIterating;
if (i <= secondsForIterating + 10)
{
d1.innerText="Elapsed time: " + i + " seconds.";
d2.style.width=i*incrementalWidth;
setTimeout("timedIterations(" + secondsForIterating + ");", 1000);
i++;
}
else
{
d1.style.visibility = "hidden";
d2.style.visibility = "hidden";
d3.innerText =
"The server is taking longer than "
+ "anticipated to process your request. "
+ "Thank you for your patience. "
}
}
</SCRIPT>
</HEAD>
<body bgColor="#96b0be" topMargin="0" onload="ProgressBar(60,0);"
MS_POSITIONING="FlowLayout">
<TABLE id="Table1" style="WIDTH: 100%; HEIGHT: 65px" borderColor="#000000"
cellSpacing="0"
cellPadding="1" border="0">
<TR>
<TD style="HEIGHT: 65px" vAlign="bottom" align="center"
bgColor="black"></TD>
<TD style="WIDTH: 797px; HEIGHT: 65px" vAlign="bottom" align="center"
width="797" background="images/BRS_Title.jpg"
colSpan="1" rowSpan="1">
<P><asp:label id="PageHeaderLabel" runat="server" Font-Names="Arial"
Font-Size="Medium" BorderStyle="None"
Font-Bold="True" ForeColor="#ffffff"></asp:label></P>
</TD>
<TD style="HEIGHT: 65px" vAlign="bottom" align="center"
bgColor="#000000"></TD>
</TR>
</TABLE>
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<TD align="center" width="100%"><font size="6">
<P><b>Please Wait
<br>
Processing for the report...</b></P>
</font>
<P><b><asp:label id="StartTimeLabel" runat="server"
EnableViewState="False" Font-Names="Arial" Font-Size="Large"
BorderStyle="None"></asp:label></b></P>
<font size="4">
<P>This report is in a new browser window.<br>
Please close this window as soon as you are finished with the report.
</P>
</font>
</TD>
</TR>
<tr>
<td align="center" width="100%"><font size="4">
<div id="d1" style="FONT-WEIGHT: bold; FONT-FAMILY: Arial"></div>
</font>
<div id="d2" style="BACKGROUND-COLOR: red"></div>
<font size="4">
<div id="d3" style="FONT-WEIGHT: bold; FONT-FAMILY: Arial"></div>
</font>
</td>
</tr>
</TABLE>
</form>
</body>
</HTML>
 
Hi Brad,

Cool.

2 things though...

Is there anything in the CodeBehind file we should know about? And whats
BRS_Vouchers.PleaseWait - is that something that's included or a component or
what?

Cheers :)

Dan
 
1) The only thing in the code behind is one line of code to populate a label
on the page with the current time.

2) I probably should have just left that line out. That is just the
reference to the code-behind page. The name of the page in my code is
"PleaseWait.aspx".
 
Back
Top