Postback

  • Thread starter Thread starter Johan
  • Start date Start date
J

Johan

I'm running a timer as a VBScript on a VB.NET webpage. The problem is
that
at postback the script seems to start all over again and the timer is
reset. Is there a way to prevent this?


<SCRIPT language="VBScript">
<!--
dim StartTime
dim Time
dim timerID


sub StartTimer()
if StartTime=0 then
StartTime=timer()
end if
timerID = setTimeout("UpdateTimer()", 1000)
end sub


sub UpdateTimer()
if Postback=true then
exit sub
end if
Time=timer()-StartTime
document.Form1.lblTimer.value=Cstr(Time)
timerID = setTimeout("UpdateTimer()", 1000)


end sub
-->
</SCRIPT>
 
With client script, you will have to set a conditional. You would be better
to emit the client script from the code behind, only when not postback.

If you want to go this direction, you will have to add a variable for
postback (emitted from code behind?). You can then use the variable to
determine if you need to set the counter, or not.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Back
Top