BeanSoftware Logo

ASP.NET Database Search Control

    Write For Us

How To Refresh An ASP.NET Page?

To refresh web page after some time period you can use HTML meta tag. This line placed inside of <head > tag will refresh web page every 10 seconds:

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


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:

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


After that, in code behind you can manipulate with refresh period. Let say you want to refresh page every 5 seconds:

[ C# ]

public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        // Set refresh period in seconds
        RefreshPeriod.Content = "5";

[ VB.NET ]

Partial Class DefaultVB
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' Set refresh period in seconds
        RefreshPeriod.Content = "5"
    End Sub
End Class

Related articles:

1. Using XML in ASP.NET
2. How To Refresh HTML Page After X Seconds?

FAQ toolbar: Submit FAQ  |  Tell A Friend  |  Add to favorites  |  Feedback

Copyright © 2002-2008 Bean Software. All rights reserved.