English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I know that you can make it so a web page auto-refreshes after a specific number of seconds. But what if I wanted to make it so a web page auto-refreshes at a specific time? For example, can I have a page auto-refresh automatically on October 30, 2006 at 7:00 PM? Is there any possible way to do this? I don't know a whole lot about code so maybe you guys can help or at least point me in the right direction, if this can be done. Thanks.

2006-10-29 20:42:33 · 5 answers · asked by . 7 in Computers & Internet Programming & Design

5 answers

Please copy & paste below script for auto refreshment: -

-----------------------------------------------------------------------------

------------------------------------------------------------------------

Change the time for each refresh by configuring variable "limit" in the script.

2006-10-29 20:46:48 · answer #1 · answered by Masud R. Khan 4 · 1 0

You can set an ASP.NET Web Page to auto refresh on a set interval. I want a DataGrid refreshed every five minutes.

Obviously, there are several methods, including Java Script. But, after searching the web for several minutes without finding an easy solution, my partner, Bill Ryan told me how to do this simple trick. It was only complicated by the fact that I have other controls on the page beside the DataGrid.

To simply refresh the web page every five minutes, you can place the "meta http-equiv...." line shown below in the HTML editor of your ASPX page. Content ="300" means refresh every 300 seconds or five minutes.


WebForm1title><br /> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"><br /> <meta content="C#" name="CODE_LANGUAGE"><br /> <!--The next line of code will refresh the page every 5 minutes--><br /> <meta http-equiv="refresh" content="300"><br /> <meta content="JavaScript" name="vs_defaultClientScript"><br /> <meta content="http://schemas.microsoft.com/intellisense/ie5" <br /> name="vs_targetSchema"><br /> HEAD> <br /> <br /> <br /> That's all there is to it, if there is only a data grid on the page! However, be aware that this refresh acts like an initial page load, and any other controls, such as Drop Down Lists, etc., which have been set to other than default values will be lost unless you do some additional coding to restore their content at the time the refresh fires.<br /> <br /> Fortunately, I had saved the contents of three Drop Down Lists, and the value of a CheckBox in Session Variables before I implemented this code. Therefore, I only have to call a new method, from the Page_Load event, to restore the controls.<br /> <br /> /// <summary><br /> /// This method will fill the controls back from session variables.<br /> /// Called because auto refresh is imitating an initial page load.<br /> /// <br /> private void ResetControlsFromSessionVariables()<br /> {<br /> // turn of autopostback so the controls won't fire<br /> this.cbFacility.AutoPostBack=false;<br /> this.cbFacility.SelectedIndex = <br /> cbFacility.Items.IndexOf(cbFacility.Items.FindByText(<br /> (string)Session["FacilityName"]));<br /> this.cbSortByList.AutoPostBack=false;<br /> this.cbSortByList.SelectedIndex = <br /> cbSortByList.Items.IndexOf(cbSortByList.Items.FindByText(<br /> (string)Session["SortField"]));<br /> this.cbStatusFilter.AutoPostBack=false;<br /> this.cbStatusFilter.SelectedIndex = <br /> cbStatusFilter.Items.IndexOf(cbStatusFilter.Items.FindByText(<br /> (string)Session["StatusFilter"]));<br /> this.chkPaging.AutoPostBack=false;<br /> if((string)Session["Paging"]=="YES")<br /> this.chkPaging.Checked=true;<br /> else<br /> this.chkPaging.Checked=false;<br /> // turn the controls back on<br /> this.cbFacility.AutoPostBack=true;<br /> this.cbSortByList.AutoPostBack=true;<br /> this.cbStatusFilter.AutoPostBack=true;<br /> this.chkPaging.AutoPostBack=true;<br /> }<br /> <br /> <br /> The DataGrid was already being refreshed on Page_Load, according to the selections in the controls being manipulated in the code shown above. The reason the code shown above uses the long lines of code to set the selected index is that, unlike a Windows ComboBox, the ASP.NET DropDownList does not contain a Text property, and the SelectedIndex.Text property is ReadOnly. </p> <p> <small> 2006-10-29 21:02:20 · <a href="#answer20061029210220">answer #2</a> · <span>answered by <u>gracious_78</u> <b>3</b></span> · <span>1<span style='color:green;'>⤊</span></span> <span>0<span style='color:red;'>⤋</span></span> </small> </p> </div> <div id="answer20061029205535" class='answer' > <!-- <b>Answer #3</b> --> <p class='answer-content' lang="en"> Nice code Masud! <br /> Thats the one you need, you have to replace codes now cause it is illegal to alter a Microsoft code. Well its sorta illegal. no it is illegal. Happy little Bill Gates use to be a programmer, and a good one. It will be a Microsoft Network, but we aill have to allow Open Source stuff on it, least untill we can buy the DoJ and the rest of the senate. </p> <p> <small> 2006-10-29 20:55:35 · <a href="#answer20061029205535">answer #3</a> · <span>answered by <u>Anonymous</u></span> · <span>1<span style='color:green;'>⤊</span></span> <span>0<span style='color:red;'>⤋</span></span> </small> </p> </div> <div id="answer20061031111518" class='answer' > <!-- <b>Answer #4</b> --> <p class='answer-content' lang="en"> love the pic. Red Lored Amazon's are amazing creatures. Mine is 13 her name is Molly. </p> <p> <small> 2006-10-31 11:15:18 · <a href="#answer20061031111518">answer #4</a> · <span>answered by <u>negbch00</u> <b>1</b></span> · <span>1<span style='color:green;'>⤊</span></span> <span>0<span style='color:red;'>⤋</span></span> </small> </p> </div> <div id="answer20161016131234" class='answer' > <!-- <b>Answer #5</b> --> <p class='answer-content' lang="en"> seem on the internet site, in many cases there is an option to instruct off the automated fresh. activities websites have it on via default b/c it rather is the only thank you to stand as much as the 2nd rankings without manually fresh. </p> <p> <small> 2016-10-16 13:12:34 · <a href="#answer20161016131234">answer #5</a> · <span>answered by <u>Anonymous</u></span> · <span>0<span style='color:green;'>⤊</span></span> <span>0<span style='color:red;'>⤋</span></span> </small> </p> </div> </div> </article> </section> <div style="background:#888;padding:8px;margin-top:16px;"> fedest.com, questions and answers </div> </body> </html>