|
|
 |
| ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

November 2nd, 2005, 07:42 AM
|
|
Registered User
|
|
Join Date: Nov 2005
Location: Hyderabad, Andhra Pradesh, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Implement Timer in asp.net
I want to implement timer in my asp.net web page.The timer should be
visible to the user as each second ticks.I have used Javascript Timer but when load is more the timer fails.
The timer code which i have used is as follows:
function det_time()
{
var mins;
var sec,sec1;
mins = Math.floor(secs/60);
sec = secs - mins*(60);
if (sec < 10)
{
sec = "0"+sec;
}
if (mins < 10)
{
mins="0"+mins;
}
window.document.Form2.hidMin.value = "a";
window.document.Form2.my_time.value = "00:" +mins + ":" + sec;
}
setInterval("det_time()", 1000);
var cnt = 0;
var secs;
var cl;
var timerID = null;
var timerRunning = false;
var delay = 1000;
function InitializeTimer()
{
secs = window.document.Form2.hidTime.value;
StartTheTimer();
}
function StopTheClock()
{
if(timerRunning);
clearTimeout(timerID);
timerRunning = false;
}
function StartTheTimer()
{
if (secs==0)
{
StopTheClock();
window.document.Form2.hidMin.value = "Auto";
window.document.Form2.submit();
}
else
{
self.status = secs;
secs = secs - 1;
timerRunning = false;
timerID = self.setTimeout(" StartTheTimer()", delay);
}
}
This i have called in page load.
I have declared 2 hidden inputs as follows:
<INPUT id="hidTime" style="Z-INDEX: 102; LEFT: 116px; POSITION: absolute; TOP: 384px" type="hidden"
name="hidTime" runat="server">
<INPUT id="hidMin" style="Z-INDEX: 103; LEFT: 587px; POSITION: absolute; TOP: 366px" type="hidden"
name="hidMin" runat="server">
Is there any better option to implement a timer in asp.net( VB)?
Malabika
__________________
Malabika
|

November 2nd, 2005, 11:24 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,328
Thanks: 0
Thanked 1 Time in 1 Post
|
|
You cannot implement it with .NET codebehind. This would cause the timer to run on the server, not the client. You need to do it on the client as you have. If you are having a javascript problem, post your code in there.
|

November 3rd, 2005, 12:29 AM
|
|
Registered User
|
|
Join Date: Nov 2005
Location: Hyderabad, Andhra Pradesh, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for quick response.
Actually the javascript timer is working perfectly fine for most of the cases.Out of 3600 people who attended the contest where i implemented this timer around 500 people faced the problem that the page is getting refreshed again and again.So i was searching for a better client side method to do this.I can post the entire code if you want both aspx and aspx. vb page.
Malabika
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |