Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 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
Default 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
  #2 (permalink)  
Old November 2nd, 2005, 11:24 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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.

  #3 (permalink)  
Old 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
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Implement Payment Gateway in asp.net raj2max ASP.NET 1.0 and 1.1 Basics 1 November 23rd, 2010 03:17 AM
Timer ( ASP.net) C# aliusmankhan ASP.NET 2.0 Professional 6 July 21st, 2008 11:21 AM
Timer control in asp.net raj2max ASP.NET 1.0 and 1.1 Basics 3 July 18th, 2007 02:13 AM
Timer in ASP.net 1.1 wunnavabk ASP.NET 1.0 and 1.1 Professional 1 May 25th, 2007 02:36 AM
Timer elapse event in asp.net inimay Visual Studio 2005 0 December 19th, 2006 07:57 AM



All times are GMT -4. The time now is 08:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.