Microsoft's ASP.NET AJAX framework ships with a mere five Web controls: the ScriptManager and ScriptManagerProxy;
the UpdatePanel; the UpdateProgress; and the Timer. Previous installments in this article series have examined all but one control, the Timer.
As we've seen from the first installment, all web pages that use the framework
must have precisely one ScriptManager control on the page. The UpdatePanel control
defines a region on the screen whose content is updated via partial page postbacks, and the UpdateProgress
control provides visual feedback during the execution of a partial page postback. The Timer
control, which is the focus of this installment, raises a postback every time a specified number of milliseconds has elapsed.
The Timer control is useful in scenarios where a portion of the screen needs to be updated every so often. For example, many financial websites display
stock quotes that are refreshed periodically. Prior to AJAX, refreshing the stock quote entailed reloading the entire document, which would result in
a screen flash and necessitate the browser re-downloading the entire content of the page (even though the only change that has occurred is the
stock quote). Using AJAX techniques we can have the page asynchronously communicate with the server to get the latest quote every n millisconds
and seamlessly update the quote on screen. The Timer control, along with the UpdatePanel, make implementing such scenarios a breeze.
This article shows how to use the Timer control to trigger a partial page postback every five seconds. It also shows how to start and stop the Timer
through both server-side and client-side code. Read on to learn more!
Read More >