Auto Postback or Refresh page for every defined time interval

The Scenario may come where application needs data to be updated automatically. The Question comes; Is there a way by which we can auto refresh a page for specific time interval so as to update the Content(automatically).

The ultimate goal is; we want to refresh our page automatically at a defined time interval. First, if you are using AJAX in your website then you can use ASP.NET AJAX > The Timer Control to achieve this. But if you are not using AJAX; then also its not a big deal.

Check out below code which will Referesh the webpage after every 10 seconds:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //page will be refereshed at a interval of 10 sec
            Response.AddHeader("Refresh", "10");
        }
    }

Alternatively, you can also add meta tag under <title> tag, in your HTML Design code as:
    <meta http-equiv="refresh" content="10;url=http://www.google.co.in">

This will Refresh / Auto Postback the current page after 10 seconds. Optionally you can also define a url which means page will be redirected to that url after specified interval (This functionality comes handy while you want your website user to have Login > See the WelCome / Logged in Successfully Page > and redirect to his Account or Home Page Automatically). if you dont spacify the url, then current page will be refereshed after specified time interval.

Comments

# Auto Postback or Refresh page for every defined time interval &laquo; KaushaL.NET

Pingback from  Auto Postback or Refresh page for every defined time interval  « KaushaL.NET

The leading UI suite for ASP.NET - Telerik radControls
Outstanding performance. Full ASP.NET AJAX support. Nearly codeless development.