Header Ads

Automatic Page Refresh in ASP.NET

Refresh a page automatically at a time of interval is pretty simple, using META tags.

<meta http-equiv="refresh" content="30">
<meta http-equiv="refresh" content="30;url=Sample.aspx">

In case of Master Pages, if you use META tag then all pages that use this master page will be refreshed, which is not desired, to accomplish this, add the following c# code in code behind page, the particular page you want to refresh:

Response.AppendHeader("Refresh", 30 + "; URL=Sample.aspx");

Where, 30 is the time interval in seconds.

There are many other ways of doing this, like using JavaScript, but this is simplest.

No comments:

Powered by Blogger.