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.
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.
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.