Reputation: 221
How to refresh page using c# in every five minutes in ASP.NET
?
Upvotes: 7
Views: 13308
Reputation: 1254
One is Javascript:
setTimeout("location.reload(true);", timeout);
The second is a Meta tag:
<meta http-equiv="refresh" content="300">
Upvotes: 7
Reputation: 3239
window.setInterval(function () {
// this will execute every 1 second
methodCallOrAction();
}, 1000);
function methodCallOrAction()
{
// u can call an url or do something here
}
Upvotes: 0
Reputation: 4657
You can't force an HTML page to refresh from the server side. The client must request the page.
The only ways to do this always involve either using the META refresh tag, the Refresh HTTP header, or else javascript which forces a page reload on an interval.
Any "server-side" solution will do it by either writing javascript or the META tag to the page. There's simply no other way to do it.
Upvotes: 2
Reputation: 886
the simplest way is
<Head>
<meta equiv="refresh" content="5">
</Head>
or use timer control to refresh a webpage for every five minutes for example: drag and drop timer control in form.aspx and in form load add the code like below
<asp:Timer ID="Timer1" runat="server" Interval="6000" ontick="Timer1_Tick" />
form load
public void DoMagic()
{
}
protected void Timer1_Tick(object sender, EventArgs e)
{
DoMagic();
Label1.Text = "";
}
Upvotes: 0
Reputation: 10366
Using the following HTML meta tag in your header <META HTTP-EQUIV="REFRESH" CONTENT="300">
should do the trick
Upvotes: 3