ASP.NET 2.0 AJAX Timer Hacks! How to Pause ASP.NET AJAX Timer.
from about 2 weeks I wrote an article about how you can use ASP.NET 2.0 AJAX Timer control in a real world scenario side by side with RssToolKit.
The idea it to display RSS feed from deferent location in cycle using ASP.NET AJAX Timer. I also had an idea of pausing the Timer when the user move his mouse over the update-able area "Group Box that display feeds inside it". Of course this should be down from client side.
I searched the documentation for Client Side APIs related to the AJAX Timer control but I didn't find any. I had to hack inside AJAX Timer client library downloaded with ASP.NET AJAX Extensions, and I found what I want.
First I though that by setting client side enabled property using set_enabled(false) of the AJAX Timer I could get what I want; actually I was wrong, this will not pause the Timer.
Dig deeper, but not for too long, I found 2 methods _startTimer() and _stopTimer(), those were excatly what I was looking for.
bellow is a sample client code of how you can use these 2 methods:
function startTimer()
{
var timer = $find("<%=ajaxTimer.ClientID%>")
timer._startTimer();
}
function stopTimer()
{
var timer = $find("<%=ajaxTimer.ClientID%>")
timer._stopTimer();
} The above code assuming that you have an AJAX Timer control on the page named ajaxTimer.
Call these method from your client side code, or add them as event handlers on your target elements.
I don't know why these are not documented, or we are not supposed to use them?! Actually I don't know.
I thought that after using these methods the browser will cause a problem regarding client scripts, but both Opera and IE worked just fine without any problem. Also I didn't notice any slow down or hanging in both browsers.
Hope you find it useful.