The Timer control enables you to perform postbacks at a specified interval. When you use the Timer control as a trigger for an UpdatePanel control, the UpdatePanel control is updated by using an asynchronous, partial-page update. You must include a ScriptManager object in a Web page to use the Timer control.
You use the Timer control to update an UpdatePanel control by including the timer inside the UpdatePanel control. Alternatively, you can place the timer outside the UpdatePanel control and set the timer as a trigger.
You can also initiate full postback of a complete Web page by including the Timer control in the Web page and not setting it as a trigger for an UpdatePanel control.
You can run server code when the timer interval has elapsed by creating an event handler for the Tick event. In the event handler, you can include code that dynamically adjusts the behavior of the Timer control.
Set the Interval property to specify how often postbacks will occur. Set the Enabled property to turn the Timer on or off.
Note: |
|---|
The accuracy of when the
Timer control posts back to the Web server depends on the accuracy of the ECMAScript (JavaScript) window.setTimeout function that is running in the browser.
|
The Interval property is defined in milliseconds. You must set the Interval property to a value that lets at least one asynchronous postback complete before the next postback is initiated. When the Timer control is outside an UpdatePanel control, the timer continues to run while the content of the UpdatePanel control is refreshed. If a new postback is initiated while an earlier postback is being processed, the first postback will be canceled. The default value is 60,000 milliseconds (60 seconds).
Note: |
|---|
Adding a
Timer control with a small value in the Interval property can generate significant traffic to and from the Web server. Use the Timer control to refresh the content only as often as necessary.
|