p2p.wrox.com 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 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.

Reply
 
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
__________________
Malabika
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old November 2nd, 2005, 11:24 AM
Friend of Wrox
Points: 4,166, Level: 27
Points: 4,166, Level: 27 Points: 4,166, Level: 27 Points: 4,166, Level: 27
Activity: 12%
Activity: 12% Activity: 12% Activity: 12%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,328
Thanks: 0
Thanked 1 Time in 1 Post
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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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



All times are GMT -4. The time now is 02:31 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc