Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 2nd, 2005, 07:42 AM
Registered User
 
Join Date: Nov 2005
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
 
Old November 2nd, 2005, 11:24 AM
Friend of Wrox
 
Join Date: Nov 2003
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.

 
Old November 3rd, 2005, 12:29 AM
Registered User
 
Join Date: Nov 2005
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





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.