Thanks Joshie for taking time for helping me out with this problem. I
think you got a good idea of what I am trying to achieve.
My dotnet app has 3 pages StartPage.aspx, WaitPage.aspx and
ResultPage.aspx.
Basic functionality is very simple, I take input from user on
StartPage.aspx.
I pass the input to ResultPage.aspx as a query string.
The result page takes the input and runs a query with that input on db.
[This query fetches around 500 records and takes around 2 min. to
retrieve results].
Until all 500 records are fetched the application just stays on the
StartPage.aspx with a busy icon and progress of the fetch in status bar
of the page.
To eliminate this wait, I introduced a WaitPage.aspx.
When the application starts processing the input on the
ResultPage.aspx, it redirects the user to the wait page. On the wait
page i call following javascript funtion redirectTo() on body onload()
of wait page.
I pass targetPage = "ResultPage.aspx", total = 500 and processed = 0.
This part works great. Now I need to update this value of processed
with the real time actual value of records that are already fetched by
the query which is running on the ResultPage.aspx.
<script>
var i = 0;
var secondsForWaiting = 30;
function redirectTo(targetPage, total, processed)
{
if ( total = 0 )
ProcessingLabel.innerText = "Establishing connection...";
if (0 < targetPage.length)
{
location.replace(targetPage);
b1.style.cursor="wait";
if (secondsForWaiting.valueOf() > 0)
{
ProcessingLabel.innerText =
"This process can take up to "
+ secondsForWaiting + " seconds..."
+ "Total records processed " + processed + " out of " +
total;
timedIterations(secondsForWaiting);
}
}
else
{
ProcessingLabel.innerText = "Page not found."
}
}
function timedIterations(secondsForIterating)
{
incrementalWidth = 600 / secondsForIterating;
if (i <= secondsForIterating + 10)
{
d1.innerText="Elapsed time: " + i + " seconds.";
d2.style.width=i*incrementalWidth;
setTimeout(
"timedIterations(" + secondsForIterating + ");",
1000);
i++;
}
else
{
b1.style.cursor="";
d1.style.visibility = "hidden";
d2.style.visibility = "hidden";
ProcessingLabel.innerText =
"The server is taking longer than "
+ "anticipated to process your request. "
+ "Thank you for your patience. "
+ "You can wait a few minutes longer for "
+ "the process to complete, or you can press "
+ "the back button and try again later...";
}
}
</script>