Introduction
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
- First use the namespace DControls
- 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.
WebTimer1.Enabled=true;
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 vb.net.
Don't hesitate to contact me if you need any help or if you have any suggestions or comments
so..... happy programming ;)
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.