.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Countdown timer counts double

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :ASP.Net

Hi there, i added a countdown timer to show seconds before page gets refreshed. But every tick counts 2 seconds instead of 1 .. so it goes from 30 > 28 > 26 instead of 30 > 29 > 28 ..

On page load I set the label value to 30.

The update panel contains following code for 2 labels and timer:

<asp:UpdatePanel ID="UpdatePanel3" runat="server">
            <asp:Label ID="lblRefresh" runat="server" Text="Volgende Refresh"></asp:Label>: 
            <asp:Label ID="lblRefreshTeller" runat="server" Text=""></asp:Label> sec
            <asp:AsyncPostBackTrigger  ControlID="Timer2" />
            <asp:Timer ID="Timer2" runat="server" Interval="1000" OnTick="Timer2_Tick"></asp:Timer>



Code behind:

Protected Sub Timer2_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Dim seconds As Integer = Integer.Parse(lblRefreshTeller.Text)
        If seconds > 0 Then

View Complete Post

More Related Resource Links

Countdown Timer for Fantasy League Draft Site

I am looking to do a countdown timer for time remaining to make a draft pick.  I have seen a number of countdown timers such as: Timer1 Timer2 Timer3In all of these timers, I'm not seeing an easy way to change the Target Date via the code behind.  The timer would need to be reset after a user makes a draft pick.I also would like the timer to be server side as opposed to client side.Any help would be appreciated.

CountDown timer for an auction



I would like if someone can help me with an script or to guide me, for an countdown timer. I have an auction site and already a end date, but what i don't know is how to do to show me how many days hours and minutes.

I read several posts here, but none of them seems to work. It doesn't show nothing

this is it what i have, on my page, and it is showing the end date, but how do i do, to show a countdown  

Please can someone hellp me


This is .cs

stoptime.Text = dr["***"].ToString();
<asp:Label id="stoptime" runat="server" Font-Bold="true" ForeColor="#0066FF" Font-Size="Small"></asp:Label>


how to use countdown timer?


<p>hi , i want to make the the page which show the countdown timer.... i have the coding in which the initial time of the countdown timer is given in the coding... but i want to enter its initial time from my data base can you help me...</p> 


my html page is given here......


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="test3.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
        <br />
    <asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">

    <asp:Label ID="Label6" runat="server">0</asp:Label>
<asp:Label ID="Label5" runat="server">0</asp:Label>
    <asp:Label ID=&qu

how to create a countdown timer using C# and ASP.NET AJAX ?


 Hi guys,

Im about to start development on a countdown timer that will display the time left for a particular product.

the format will be like this - 00:00:11.

I have been watching the AJAX video tutorials so im thinking of approaching this by setting an updatePannel with a timer with a tick event every 1000ms. Inside the updatePannel i could have a label that is attached to a C# method that contains the countdown logic

2 questions...

1: is this a good way forward or not.

2: can anyone suggest data time classes/methods that i will find useful so for example an admin can enter a start date and an end date and the timer will show the days, hours, minutes and seconds remaining.

the site im trying to emulate is this ... http://www.telebid.com/ looks like they have AJAX countdown timers too.

thank you for your help


Url rewrite with timer



I'm trying to rewrite my urls, which kinda work now.

The problem is that in my page i'm using a timer to refresh the data every couple of seconds.
But in Mozilla firebug I can see that the url keeps changing: it's getting bigger after each timer update, like this:


etc etc, until it returns a 404 not found.

What can I do to prevent this?


Timers: Comparing the Timer Classes in the .NET Framework Class Library


Timers often play an important role in both client applications and server-based components (including Windows services). Writing effective timer-driven managed code requires a clear understanding of program flow and the subtleties of the .NET threading model. The .NET Framework Class Library provides three different timer classes: System.Windows.Forms.Timer, System.Timers.Timer, and System.Threading.Timer. Each of these classes has been designed and optimized for use in different situations. This article examines the three timer classes and helps you gain an understanding of how and when each class should be used.

Alex Calvo

MSDN Magazine February 2004

Erro While Creating a Solution Package With a timer Job


Hi All,

I am trying to create a test Timer job in SharePoint and want it to be deployed as a solution package. I am using a web application project and added Timerjob.cs, fetaurereceiver.cs, feature.xml and manifest.cml files in in. Then I created a .dff file to arrange the solution package. But when I tried to create a solution package with makecab.exe i got the below error

100.00% flushing current folder

I dont know what to do with that . Please if anyone can send me an example where a timer job was deployed as a solution package it will be of great help




Isha kapoor My SharePoint Blog Follow me

Hello everyone, javascript countdown ?


Hello everyone , i am new to the environment of Asp.net, have been using it for two months now, and a problem arised when trying to create  a session timeout,

i wan a countdown time to be displayed on my page i have tried numerous things but no luck yet, tried some scripts i created myself but they do not seems to work

or I am probably not calling them correctly, i have found numerous javascripts to handle this but i still cannot seem to make them work, does anyone know how to call a script function

from asp.net using VB, Like once session timeout reaches 5 minutes which is equivalent to 300,000  i want  my timer to be displayed on screen and start counting down


this is a script i found online , not mine and it should work but i cannot seem to make it work, is it something with FormsAuthentication

or RegisterStartup Script i do not know


var timeout = '<%= Session.Timeout * 60 * 1000 %>';
           var timer = setInterval(
               function ()

causing 500 server error :(


So, I'm just learning ASP.NET with C#, but this code just makes the page display a "500 - server error page"

the webpage is here: hereswhereyourewrong.net/aspnettest.aspx

the code is as follows:

<%@ Page Language="C#" AutoEventWireup="true" %>
<!-- This program throws up an Error 500: Server Error -->
<!-- I'm not sure why, it compiles just fine. -->
<!-- The last time it was because I had asp:TextBox fields not in a form -->
<!-- but here I just don't know -->
    <head runat="server" >
        <title>ASP.NET With C# Test</title>
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
                timeText.Text = DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss");

            public void updateTime(object sender, EventArgs e)
                timeText.Text = DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss");
        <div style="text-align: center;">
            <form runat="server" ID="timerForm">
                <asp:ScriptManager ID=

Timer delay

Hi guys, Please can one of you help me out. I have a bit of a trouble with the timer, it delay of 10 seconds which it should be of 5 seconds when I started the timer.   here it is the code Public Class Form1 Dim cPos As Point Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cPos = Windows.Forms.Cursor.Position End Sub Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick If Me.Panel1.ClientRectangle.Contains(Me.Panel1.PointToClient(Windows.Forms.Cursor.Position)) Then Me.Panel1.Show() If Panel1.Visible = True Then Timer1.Interval = 5000 Timer1.Start() Dim nPos As Point = Windows.Forms.Cursor.Position If cPos <> nPos Then cPos = nPos Else MessageBox.Show("mouse NOT moved in last 5 secs.") Panel1.Visible = False Timer2.Enabled = True End If End If End If End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick Dim nPos As Point = Windows.Forms.Cursor.Position If cPos <> nPos Then cPos = nPos If Panel1.Visible = False Then If Me.Panel1.ClientRectangle.Contains(Me.Panel1.PointToClient(Windows.Forms.Cursor.Position)) Then Panel1.Visib

Timer usage in a class library

Hi all,     I have a class library, inside a class of this library i want to use a timer, such that for every one second a slot should be called. The code for this is as follows: </>public void OnDataReceive() { System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer(); t1.Enabled = true; t1.Interval = 500; t1.Start(); t1.Tick += new EventHandler(t1_Tick); }   public void t1_Tick(object sender, EventArgs e) { OnReceive(); }   But it is not reaching to this function itself "t1_Tick", Could some one tell me what is wrong in this??? Thanks for any help

Split List into sub lists of List of size n

Hi all,   I've been playing around for a little bit trying to find the best way of taking a List<double> of variable size and splitting it in to sub-lists of  size n. So maybe a method stub like   public List<List<double>> splitData(int width,List<double> data) { <br/> }<br/> The problem is i cant get my head around how to iterate through the parameter "data" properly when the data.count is not exactly divisible by the parameter "width". I have been trying for loops but i think i need to switch to do whiles.   I'm not massively familiar with LINQ but could anyone advise if LINQ would provide an alternative way of doing it?   Any help much appreciated   John

two adjacent double quotes in json causes blue screen by JavaScriptSerializer

Hello, I am using System.Web.Script.Serialization.JavaScriptSerializer to deserialize  http requests.  I get the blue screen when the contents I am deserializing has two double quotes, for example:  ""country"". Is there a fix for this?  Currently I replace the "" with a special string and then I deserialization, then I put back the "".  I do this for a given field in the object which I've seen comes in with ""s.  The problem is that I should be doing this for all fields in the input json.  This is a lot of extra code to write as I could be deserializing many different types of Json objects.  The "" is needed by the client to specify a quoted string, so I can't ask for the input to be changed. Any help on this subject would be really appreciated. Many thanks.     I am using .Net framework 3.5.

Custom SharePoint Timer Job doesn't run after changing code and restart timer services.

Hi We are facing an issue that our custom SharePonit Timer Job doesn't run after a changing the code. First, we developed and deployed a timer job. It worked fine for a few days, then we detected a memory leak and killed the OWSTIMER.EXE. (Maybe we should uninstall the timer job and restart the timer services nicely). We fixed the problem, redeployed the fix as a feature (assemblies are re-GACed ...) to our small SharePoint farm (one web server, one services server), restarted the SharePonit Timer Services. Now we can see the time job in Timer Job Definition in Central Admin but the job never runs (Since it doesn't run, the timer job status page doesn't have any info about it). We tried the same process in a dev environment with SharePoint signle box installation. The timer job just works fine. I did some search on Internet and followed some instruction to clear the cache from "C:\ProgramData\Microsoft\SharePoint\Config\1d50d73c-9bf1-4444-85a9-910ed050d1bf" by 1. Remove all the xml2. Clear the cache.ini with "1".3. restart the timer services. It still doesn't fix the problem.Please advise what else I can do. I even rename the timer job and redeploy it. It doesn't help. I checked the even log and SharePoing log and couldn't see anything wrong. Our OS is W2K8.         public override void FeatureActivated(SPFeatureReceiverProperties properties)        { 

Timer in Web Service

Hi I have a web service (asmx). I want to add a functionality where in I have to do polling for data on a URL. I added a timer and in the timer elapsed event handler I am checking for the data. Is it a good design? Is there something better than timer for this in ASP.NET? I have a issue with this where in the site / IIS goes in ideal state because of no requests, I have posted it in other forum on how to solve this problem. What I wanted to verify is that, use of timer is a valid thing for my use case, or I should go for some other approach? Will it be too heavy operation for the service to have a timer of 5 minutes interval running in over there, which will be running for the lifetime of this application.  

double.IsNaN throwing ArithmeticException

I have problem when calling double.IsNaN method. It is throwing an ArithmeticException. With a message like "Overflow or underflow in the arithmetic operation." Any ideas as to what is causing this problem?

double spin text in richtextbox

i want to implement this feature : if i have a following sentence : {my name is james vick and iam a {member|user|visitor} on this {forum|website|site} and iam loving it | iam admin and iam a {supervisor|admin|moderator} on this {forum|website|site} and iam loving it} on a click of button i want to generate this : my name is james vick and iam a member on this site and iam loving it or iam admin and iam a admin on this forum and iam loving it The basic need is to randomly choose words between {|} braces I have been able to do this for inner nest i.e. for {member|user|visitor}. But how to include the outer nest of sentences also i.e. {something blah blah {blah1|blah2} and | something else} ? code for inner nest : Private Sub SimpleButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton3.Click Dim stringWithTextIn As String = RichTextBox1.Text Dim regex As New Regex("{(.*?)}") Dim r As String = regex.Replace(stringWithTextIn, New MatchEvaluator(AddressOf ReplaceMatch)) RichTextBox2.Text = r End Sub Private Function ReplaceMatch(ByVal m As Match) As String Dim parts = m.Groups(1).Value.Split("|"c) Return parts(r.Next(0, parts.Length)) End Function i know i just have to change the regex but what do i add in it to include outer braces?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend