Wednesday, September 07, 2011

How to Refresh an ASP.NET Page automatically

Posted by Rahul Kharde at 9:11 PM

There are several methods to refresh page.

Method 1

To refresh web page after some time period you can use HTML meta tag. This line placed inside of tag will refresh web page every 1 seconds, Content ="1" means refresh every 1 seconds

<title>Untitled Page
<meta http-equiv="refresh" content="1"/>

Method 2

Add below code into the ASP page, it will refresh the page after every 1 second, here 1000 means refresh every 1 second.

ScriptManager.RegisterStartupScript(this,this.GetType(), "refresh", "window.setTimeout('window.location.reload(true);',1000);", true);

Method 3

You can implement this dynamically too. Let say that this refresh period is not constant and you need to be able to change it in settings area of your ASP.NET application. You can achieve this if you set ID parameter and add runat="server" part, like this:

<head runat="server">

<title>Untitled Page</title>

<meta id="RefreshPeriod" runat="server" http-equiv="refresh" content="10" />


Code behind

protected void Page_Load(object sender, EventArgs e)


RefreshPeriod.Content = "1";


If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you subscribe to my regular Email Updates. Subscribe Now!

Kindly Bookmark and Share it:



Have any question? Feel Free To Post Below:


Popular Posts

Recent Comments

© 2011. All Rights Reserved | Help to understand .Net | Template by Blogger Widgets

Home | About | Top