Auto-refresh an ASP.NET.aspx web page

8:43:00 pm 0 Comments

Automatic web page refresh can be implemented in an ASP.NET (.aspx) web-page by adding some HTML code in the header section.

You can simply add following line of code in the Header section to enable auto refresh in an ASP.NET web page.
<meta http-equiv="refresh" content="15">
Where 15 refers to the number of seconds it will take before refreshing the page.
Also you can redirect to a specific page if you put the URL inside the tag.
<meta http-equiv="refresh" content="15; url=http://www.srlinfotech.com">
In reality, this is standard HTML functionality and nothing specific to ASP.NET. The same effect of auto-refresh would be seen whether it is an ASP.NET page or just a HTML page, or a page made in Java, PHP, ColdFusion, Perl or the like.

If you want to set the refresh time dynamically then that can be done in ASP.NET by adding server side code in the Page_Load function to set it, as shown below:
Response.AppendHeader("Refresh", "15")

0 comments: