Refreshing the page on Interval basis

If you ever wanted to refresh a portion of your page on a certain interval, it does not get any easier with asp.net Ajax. Simply surround the content with an Update Panel and trigger the update of the Update Panel using the timer control. Here is the markup that illustrates this example.

image

image

In the code above, I have an Update Panel which contains a label that will display the current date. Update Panel has a trigger for Timer control that forces Update Panel to refresh itself every 3 milliseconds. The timer control has an interval event which default to 1 minute meaning every 1 minute timer control will fire tick event on the server. If time control is not made a trigger for Update Panel, it would cause a normal postback. Therefore if you want the update Panel to refresh asynchronously, than set timer control as a trigger for Update Panel. In order to refresh the date in my Update Panel, I register for the tick event of the time control and Update the date label with the new date.

1 Comment

  • Exelent!

    It is a very good solution for my problem, I had to show stock market value in the master page, without refreshing the contentplaceholder, By using this concept, my problem has solved.

    Thank you.

Comments have been disabled for this content.