Steven
Steven

Reputation: 13769

Add GET Refresh Parameter in ASPX

How do I add an auto-refresh feature based on the value of a GET parameter?

For example, "http://localhost/myPage.aspx?refresh=5" would auto-refresh the page every 5 minutes.

NOTE: A VB code example is preferred.

Upvotes: 0

Views: 550

Answers (1)

Chris Shouts
Chris Shouts

Reputation: 5437

Here is one way to do it - an alternative would be to to use javascript to force a refresh or get just the content you need, but this should work fine for a simple full-page refresh.

The following code should be added to the OnLoad handler of the page you want to refresh.

Dim secondsToRefresh As Integer
If Integer.TryParse(Request.QueryString("refresh"), secondsToRefresh) Then
    secondsToRefresh *= 60
    Page.Header.Controls.Add(New HtmlMeta() With {.HttpEquiv = "Refresh", .Content = secondsToRefresh.ToString()})
End If

Please note that I'm really a C# guy at heart, as such this VB.NET code is untested.

Upvotes: 1

Related Questions