Auto Refresh Web Page





The Meta tag Refresh has been around for a long time. Often you see it when an old web page has moved to a new web page. You usually put the meta tag in the header of your page. The syntax is:
<meta http-equiv="Refresh" content="n;url">
Where n is the number of seconds
And url is the url to refresh to.
If you leave the url off then the page refreshes itself.

In this sample code, the page updates the current time every 3 seconds. In the pageload event I have this code to set the meta tag:
if (Page.Header != null)
{
 HtmlHead hh = this.Page.Header;
 HtmlMeta hm = new HtmlMeta();
 hm.Attributes.Add("http-equiv", "Refresh");
 hm.Attributes.Add("content", "3");
 hh.Controls.Add(hm);
}

You can place this code in any other event which depends on your requirement like
if you need to refresh page after an event is fired.

When using Master Page, given code can be altered as:


if (this.Master.Page.Header != null)
{
 HtmlHead hh = this.Master.Page.Header;
 HtmlMeta hm = new HtmlMeta();
 hm.Attributes.Add("http-equiv", "Refresh");
 hm.Attributes.Add("content", "3");
 hh.Controls.Add(hm);
}
Hope it hepls!


Meta Tags Optimising Your Website for Internet Search EnginesVariations in use of meta tag descriptions by Web pages in different languages [An article from: Information Processing and Management]A co-training framework for searching XML documents [An article from: Information Systems]HTML5: Up and Running

Popular Posts