tags:

views:

282

answers:

5

Hi, I want to refresh a page on a specific time.

From http-equiv="refresh" content="30" the page is refresh very 30 seconds,But I want page is refreshed on the specific time. like page is refresh on 1:30 of every day.

A: 

Refreshing the page means sending a request to the server. You can write a Windows Service that sends a request to your page every day at 1:30.

Darin Dimitrov
+3  A: 

You could use javascript to create a countdown timer that starts when the page is loaded in the browser?

Add this to your page:

<script language="javascript" type="text/javascript">
  setTimeout("window.location = 'yourpage.aspx'", <%= CalcMilisecsToNext130pm() %>);
</script>

You could probably hack something together inline to get the number of milliseconds until 1:30pm. Else just create simple method in your codebehind...

Jakob Gade
A: 

I'd suggest you use JavaScript on page load to calculate the time difference between now and when you want to next load the page. Then set a timeout (window.setInterval) to occur at that time. Then you can set the JavaScript "location" to the same page and presto - page loads at the scheduled time.

Jakob beat me to it! :)

Bernhard Hofmann
+1  A: 
DateTime targetDate = ...;
long secondsTilRefresh = Math.Floor((targetDate - DateTime.Now).TotalSeconds);

Then, just use that value to fill the meta refresh tag. Of course, their browser may not remain open that long, and/or the browser may not support large values.

Matthew Flaschen
A: 

Server time put this:

<% DateTime dte = DateTime.Now; %>
<meta http-equiv="refresh" content="<%=86400 - (((dte.Hour * 60) + dte.Minute) * 60) %>">

for client based time use the javascript setTimeout method.

sam munkes
This is not working,have you check this code? :)
Vijjendra