Click here to Skip to main content
15,124,353 members
Articles / Web Development / ASP.NET
Posted 18 May 2006


37 bookmarked

Timer Control for web applications

Rate me:
Please Sign up or sign in to vote.
3.26/5 (18 votes)
23 Apr 2007CPOL2 min read
Web based timer control in


A web timer control that can be used to execute certain functionalities in a regular interval. As per my control, the scope of functionality involves posting back the web page and triggering the execution of a client side JavaScript method.

In web application environment we lack a proper timer control just like we have in windows application development environment. This is one of the main reasons why I went in search of a web based timer control. I tried a lotz of search in net to find a suitable web based timer control code or for an idea which we can use in web application and can be controlled from the code behind, and i ended up in codeproject. I got an article by TCDooM where he posted one of his creations i.e. a custom timer control which we can use in web apps. Thanx TCDooM :)

His article and his work really helped me to complete this control. The base of my control is the contribution of TCDooM's work.

Tech Talk

This control is pretty easy to use and you can make use of it with the help of a few properties. Just add the files into your page and then drag and drop to any page and call the timer object.

I am not going to explain the code because the code is that much simple and straight forward that any newbie in ASP.Net can understand.
So let me give an overview

  1. First use the namespace DControls
  2. This web timer has mainly two functions.
    Either it will post back the parent page in regular intervals or we can execute a client side JavaScript function in regular intervals.

    a. WebTimer1.SetTimerAction = Timer.TimerAction.Postback_Page;<br />b. WebTimer1.SetTimerAction = Timer.TimerAction.Execute_JSFunction;<br />i. WebTimer1.SetJSFunctionName = "ClientJSFunction()";

3. Timer will be disabled by default.

4. Intervals you can specify in minutes or seconds or milliseconds. Minute is default. Then set the interval duration.

WebTimer1.Interval = 30;<br />WebTimer1.SetIntervalMode = Timer.IntervalMode.Seconds;5. If you set the timer action as Postback_Page then in the code behind you have to use a property called IsPostedBackByTimer which will tell you whether the page is posted back by timer or by any other events.

if(Page.IsPostBack)<br />{<br />if(WebTimer1.IsPostedBackByTimer)<br />{<br />Response.Write("Page Posted Back By WebTimer");<br />}<br />}

Currently I used C# but anybody can easily convert into

Don't hesitate to contact me if you need any help or if you have any suggestions or comments

so..... happy programming ;)


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Deepson Thomas
Web Developer
India India
He has got software development experience of 6+ years in ASP.NET , C# , VB.Net, ASP 3.0, PHP, MS SQL, WebServices and XML. He spends his time reading / writing technical articles, wandering thru net for interesting and weird technologies. He enjoys music all the time and has a passion of watching sci-fi and classic Hollywood movies.

Comments and Discussions

GeneralMy vote of 5 Pin
Dan Randolph17-Aug-13 9:37
MemberDan Randolph17-Aug-13 9:37 
Sweet and simple
GeneralRe: My vote of 5 Pin
Deepson Thomas1-May-16 8:22
MemberDeepson Thomas1-May-16 8:22 
QuestionWebTimer1.IsPostedBackByTimer value came false even for timer Post back Pin
prem466614-Aug-12 6:37
Memberprem466614-Aug-12 6:37 
GeneralMy vote of 5 Pin
Member 88055004-Jun-12 2:14
MemberMember 88055004-Jun-12 2:14 
GeneralMy vote of 1 Pin
riyazb13-Jul-10 20:38
Memberriyazb13-Jul-10 20:38 
QuestionHow to keep track of the start and stop timer duration? Pin
avishekrc17-Mar-10 6:52
Memberavishekrc17-Mar-10 6:52 
GeneralAyax Pin
mbaocha6-May-09 18:39
Membermbaocha6-May-09 18:39 
GeneralCheck out this... Pin
Prem Rajadattan30-Sep-08 6:31
MemberPrem Rajadattan30-Sep-08 6:31 
Generalsetting a time for my project Pin
mohammadhussain19-May-08 20:33
Membermohammadhussain19-May-08 20:33 
QuestionDo you have this code in AJAX Pin
YossiKahlon13-Jul-07 10:52
MemberYossiKahlon13-Jul-07 10:52 
GeneralI hope I'm not just stupid! Pin
Michael1015-Jun-07 18:03
MemberMichael1015-Jun-07 18:03 
GeneralRe: I hope I'm not just stupid! Pin
Michael1015-Jun-07 19:17
MemberMichael1015-Jun-07 19:17 
GeneralRe: I hope I'm not just stupid! Pin
Deepson Thomas5-Jun-07 20:45
MemberDeepson Thomas5-Jun-07 20:45 
GeneralRe: I hope I'm not just stupid! Pin
manisha agarwal28-Aug-08 6:55
Membermanisha agarwal28-Aug-08 6:55 
Generalexception Pin
jijog27-Apr-07 21:59
Memberjijog27-Apr-07 21:59 
GeneralRe: exception Pin
Deepson Thomas6-May-07 23:13
MemberDeepson Thomas6-May-07 23:13 
Generalhi can i just use it to create a delay in my application Pin
rama charan26-Apr-07 22:17
Memberrama charan26-Apr-07 22:17 
GeneralRe: hi can i just use it to create a delay in my application Pin
Deepson Thomas6-May-07 23:15
MemberDeepson Thomas6-May-07 23:15 
GeneralRe: hi can i just use it to create a delay in my application Pin
rama charan7-May-07 8:52
Memberrama charan7-May-07 8:52 
GeneralRe: hi can i just use it to create a delay in my application Pin
raju jani22-Aug-14 20:40
Memberraju jani22-Aug-14 20:40 
QuestionWhy does not a server control ? Pin
Maxim Kurdukov18-May-06 20:09
MemberMaxim Kurdukov18-May-06 20:09 
AnswerRe: Why does not a server control ? Pin
Deepson Thomas21-May-06 1:40
MemberDeepson Thomas21-May-06 1:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.