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
<head>
<title>Untitled Page</title>
<meta http-equiv="refresh" content="1"/>
</head>
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" />
</head>
Code behind
protected void Page_Load(object sender, EventArgs e)
{
RefreshPeriod.Content = "1";
}
Comments
Post a Comment