E
Eric
Hi,
On my asp.net page (full dynamically build) I have a panel with a selection
possibility for the user and a submit button.
When the user clicks the submit button the code behind is collecting a lot
of data from the server and that can take up to 5 minutes.
To give the user some idea of time, I would like to show some kind of
upcounter that shows minutes and seconds and starts running when the button
has been pressed.
I found some script on the web but I have not really an idea how to use it.
basically I would like to start this counter just before it does the
postback to the server, so while the page is then waiting for the data, the
counter is going up.
Is this possible and how do I do that?
rg,
Eric
On my asp.net page (full dynamically build) I have a panel with a selection
possibility for the user and a submit button.
When the user clicks the submit button the code behind is collecting a lot
of data from the server and that can take up to 5 minutes.
To give the user some idea of time, I would like to show some kind of
upcounter that shows minutes and seconds and starts running when the button
has been pressed.
I found some script on the web but I have not really an idea how to use it.
Code:
Dim sb As New StringBuilder
sb.AppendLine("<script>function showElapsedTime()")
sb.AppendLine("{")
sb.AppendLine("// Description:")
sb.AppendLine("// This is a countup script from a specific date in the
past.")
sb.AppendLine("// It shows the days, hours, minutes and seconds that
have elapsed since the start date.")
sb.AppendLine("// For added effect, the elapsed time is updated each
second.")
sb.AppendLine("//")
sb.AppendLine("// Set the starting date details.")
sb.AppendLine("var startYear = 2007;")
sb.AppendLine("var startMonth = 11; // must be between 0 - 11")
sb.AppendLine("var startDay = 21; // must be between 1 - 31")
sb.AppendLine("var startHour = 0; // must be between 0 - 23")
sb.AppendLine("var startMinute = 0; // must be between 0 - 59")
sb.AppendLine("var startSecond = 0; // must be between 0 - 59")
sb.AppendLine("var startDate = new Date();")
sb.AppendLine("startDate.setYear(startYear);")
sb.AppendLine("startDate.setMonth(startMonth);")
sb.AppendLine("startDate.setDate(startDay);")
sb.AppendLine("startDate.setHours(startHour);")
sb.AppendLine("startDate.setMinutes(startMinute);")
sb.AppendLine("startDate.setSeconds(startSecond);")
sb.AppendLine("var rightNow = new Date();")
sb.AppendLine("var elapsedTime = rightNow.getTime() -
startDate.getTime();")
sb.AppendLine("var one_day=1000*60*60*24;")
sb.AppendLine("var elapsedDays = Math.floor( elapsedTime / one_day );")
sb.AppendLine("var milliSecondsRemaining = elapsedTime % one_day;")
sb.AppendLine("var one_hour = 1000*60*60;")
sb.AppendLine("var elapsedHours = Math.floor(milliSecondsRemaining /
one_hour );")
sb.AppendLine("milliSecondsRemaining = milliSecondsRemaining % one_hour;")
sb.AppendLine("var one_minute = 1000*60;")
sb.AppendLine("var elapsedMinutes = Math.floor(milliSecondsRemaining /
one_minute );")
sb.AppendLine("milliSecondsRemaining = milliSecondsRemaining %
one_minute;")
sb.AppendLine("var one_second = 1000;")
sb.AppendLine("var elapsedSeconds = Math.round(milliSecondsRemaining /
one_second);")
sb.AppendLine("document.getElementById('pnTimer').innerHTML =
elapsedDays + ' Days ' + elapsedHours + ' Hours ' + elapsedMinutes + '
Minutes ' + elapsedSeconds + ' Seconds';")
sb.AppendLine("t = setTimeout('showElapsedTime()',1000);")
sb.AppendLine("}")
sb.AppendLine("</script>")
ClientScript.RegisterOnSubmitStatement(Me.GetType(), "timer", sb.ToString)
basically I would like to start this counter just before it does the
postback to the server, so while the page is then waiting for the data, the
counter is going up.
Is this possible and how do I do that?
rg,
Eric