Postback

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>
 
G

Guest

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!
***************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,242
Latest member
KendrickKo

Latest Threads

Top