Solved

Refresh page every coouple minutes

Posted on 2011-02-17
5
1,470 Views
Last Modified: 2012-05-11
I need to refresh my aspx page every couple of minutes.  i found some code behind that does what I want but how do i call it automatically to refresh.  I have a datagrtid on the page that i want to refresh with new records ervery couple minutes. I can call it via a link button to refresh but how can it do it automatically or where do I put the refresh command.
Public Sub refreshpage()
        FillGrid()

        Dim meta As New HtmlMeta
        Dim HEAD As HtmlHead = DirectCast(Page.Header, HtmlHead)
        meta.HttpEquiv = "refresh"
        meta.Content = "2"
        HEAD.Controls.Add(meta)
    End Sub

Open in new window

0
Comment
Question by:kdeutsch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 34916969
Rather than the codebehind, put a meta refresh tag in the page itself:
     <meta http-equiv="refresh" content="600">
...where 600 is the number of seconds between refreshes.

Make sure this is a view-only page or you'll piss people off.
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34917048
Altenative way.
I got this code, somewhere from net

<!-- Codes by Quackit.com --><html><head><script type="text/JavaScript"><!--function timedRefresh(timeoutPeriod) { setTimeout("location.reload(true);",timeoutPeriod);}//   --></script></head><body onload="JavaScript:timedRefresh(5000);"><p>This page will refresh every 5 seconds. This is because we're using the 'onload' event to call our function. We are passing in the value '5000', which equals 5 seconds.</p><p>But hey, try not to annoy your users too much with unnecessary page refreshes every few seconds!</p></body></html>


0
 
LVL 8

Accepted Solution

by:
TheMozz earned 350 total points
ID: 34917193
asp.net has a neat little timer control for just this purpose:
http://ajax.net-tutorials.com/controls/timer-control/
0
 
LVL 8

Expert Comment

by:TheMozz
ID: 34917201
Forgot to mention the timer is completely controllable from code behind as well, so it can be enabled/disabled, and the interval can be changed as desired in the code behind.
0
 

Author Closing Comment

by:kdeutsch
ID: 34917766
This is the best way to refresh only my gridview and not all the page.  Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question