473,909 Members | 5,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

auto refresh web page

hello,
I am looking for a way to auto refresh a web page that I created, but
also let the user choose to stop the auto refresh. I can not figure out how
to stop the auto refresh. Any help would be appreciated.

Thanks,
Brian
Nov 21 '05 #1
7 22792
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If Me.CheckBox1.Ch ecked Then
Context.Respons e.AddHeader("RE FRESH", "2")
End If
End Sub

Set CheckBox1.AutoP ostBack= True

"Brian" wrote:
hello,
I am looking for a way to auto refresh a web page that I created, but
also let the user choose to stop the auto refresh. I can not figure out how
to stop the auto refresh. Any help would be appreciated.

Thanks,
Brian

Nov 21 '05 #2
Hi Brian,

you can use too:
Enable Auto-Refresh (5 seconds):
Response.Write( "<META HTTP-EQUIV=Refresh CONTENT='5'>")
Disable Auto-Refresh:
Response.Write( "<META HTTP-EQUIV=Refresh CONTENT='5'>")

I hope that helps.

Jorge Serrano Pérez
MVP VB.NET

"Brian" wrote:
hello,
I am looking for a way to auto refresh a web page that I created, but
also let the user choose to stop the auto refresh. I can not figure out how
to stop the auto refresh. Any help would be appreciated.

Thanks,
Brian

Nov 21 '05 #3
I'm sorry, my fingers have been too fast! O:-)

Disable Auto-Refresh;
Response.Write( "<META HTTP-EQUIV=Refresh CONTENT=''>")

Now it's ok.


"Jorge Serrano [MVP VB]" wrote:
Hi Brian,

you can use too:
Enable Auto-Refresh (5 seconds):
Response.Write( "<META HTTP-EQUIV=Refresh CONTENT='5'>")
Disable Auto-Refresh:
Response.Write( "<META HTTP-EQUIV=Refresh CONTENT='5'>")

I hope that helps.

Jorge Serrano Pérez
MVP VB.NET

"Brian" wrote:
hello,
I am looking for a way to auto refresh a web page that I created, but
also let the user choose to stop the auto refresh. I can not figure out how
to stop the auto refresh. Any help would be appreciated.

Thanks,
Brian

Nov 21 '05 #4
Thanks. I only have one problem. I have a button that I change the text of
from Start to Stop and vice versa, but the code only sees the first setting
"Stop" The form updates, but the code never sees the new value "Run". I
hope that was clear enough. Any Ideas?

Thanks,
Brian

"Jorge Serrano [MVP VB]" wrote:
I'm sorry, my fingers have been too fast! O:-)

Disable Auto-Refresh;
Response.Write( "<META HTTP-EQUIV=Refresh CONTENT=''>")

Now it's ok.


"Jorge Serrano [MVP VB]" wrote:
Hi Brian,

you can use too:
Enable Auto-Refresh (5 seconds):
Response.Write( "<META HTTP-EQUIV=Refresh CONTENT='5'>")
Disable Auto-Refresh:
Response.Write( "<META HTTP-EQUIV=Refresh CONTENT='5'>")

I hope that helps.

Jorge Serrano Pérez
MVP VB.NET

"Brian" wrote:
hello,
I am looking for a way to auto refresh a web page that I created, but
also let the user choose to stop the auto refresh. I can not figure out how
to stop the auto refresh. Any help would be appreciated.

Thanks,
Brian

Nov 21 '05 #5
Hi Brian,

Though the <META HTTP-EQUIV=Refresh CONTENT ... > html header is ok for
contantly refreshing a page, but since you also need to let the enduser
start and stop the refreshing, I think maybe use javascript function to
auto refresh(in fact we do it via submit the page) is better. We can just
use the
"window.setInte rval()" and "document.f orms[0].submit()" to autopost the
page. And since the
"window.setInte rval()" will return a timeid , we can store it in a page
scope javascript variable and then when user want to stop the autopostback,
we just cancel the Interval via this timeid. Also, we need to put an
additioal html intput hidden element to store the current state (start or
stop) so that when the after post back, we can remain the page's last
state. Anyway, to make it clear, here is a simple demo page I've made, you
can have a test on your side to see whether it works:

=============== aspx page=========== ========
<HTML>
<HEAD>
<title>autorefr esh</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
<script language="javas cript">
var tid;

function ControlRefresh( btn)
{
var hd = document.getEle mentById("hdSta te");
if(btn.value == "Start")
{
tid = window.setInter val("AutoRefres h()",3000);
btn.value = "Stop";
hd.value = "on";
}
else
{
window.clearInt erval(tid);
btn.value = "Start";
hd.value = "off";
}
}

function AutoRefresh()
{
document.forms[0].submit();
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td><INPUT id="btnControl " type="button" value="Start"
onclick="Contro lRefresh(this)" ></td>
</tr>
<tr>
<td><INPUT id="hdState" type="hidden" name="hdState" runat="server"
value="off"></td>
</tr>
<tr>
<td>
<asp:Button id="btnPostBack " runat="server" Text="Server Button Post
Back"></asp:Button></td>
</tr>
</table>
</form>
</body>
</HTML>

=============co de behind========= ========
public class autorefresh : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Butt on btnPostBack;
protected System.Web.UI.H tmlControls.Htm lInputHidden hdState;

private void Page_Load(objec t sender, System.EventArg s e)
{
if(IsPostBack)
{
Response.Write( "<br>Page_L oad fired at: " +
DateTime.Now.To LongTimeString( ));

if(hdState.Valu e == "on")
{
Page.RegisterSt artupScript("in it_refresh","<s cript
language='javas cript'>document .getElementById ('btnControl'). click();</script
");

}
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}

private void InitializeCompo nent()
{
this.btnPostBac k.Click += new
System.EventHan dler(this.btnPo stBack_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void btnPostBack_Cli ck(object sender, System.EventArg s e)
{
Response.Write( "<br>Server Button is clicked at: " +
DateTime.Now.To LongTimeString( ));
}
}
=============== ===============

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 21 '05 #6
Thanks for the reply. Unfortunatly I had to rush the program into
production, so I ended up making a second web page the was a copy of the
first with out the counter. I will give this a try though and see if I can
improve what I have now. Thanks. Brian

"Steven Cheng[MSFT]" wrote:
Hi Brian,

Though the <META HTTP-EQUIV=Refresh CONTENT ... > html header is ok for
contantly refreshing a page, but since you also need to let the enduser
start and stop the refreshing, I think maybe use javascript function to
auto refresh(in fact we do it via submit the page) is better. We can just
use the
"window.setInte rval()" and "document.f orms[0].submit()" to autopost the
page. And since the
"window.setInte rval()" will return a timeid , we can store it in a page
scope javascript variable and then when user want to stop the autopostback,
we just cancel the Interval via this timeid. Also, we need to put an
additioal html intput hidden element to store the current state (start or
stop) so that when the after post back, we can remain the page's last
state. Anyway, to make it clear, here is a simple demo page I've made, you
can have a test on your side to see whether it works:

=============== aspx page=========== ========
<HTML>
<HEAD>
<title>autorefr esh</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
<script language="javas cript">
var tid;

function ControlRefresh( btn)
{
var hd = document.getEle mentById("hdSta te");
if(btn.value == "Start")
{
tid = window.setInter val("AutoRefres h()",3000);
btn.value = "Stop";
hd.value = "on";
}
else
{
window.clearInt erval(tid);
btn.value = "Start";
hd.value = "off";
}
}

function AutoRefresh()
{
document.forms[0].submit();
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td><INPUT id="btnControl " type="button" value="Start"
onclick="Contro lRefresh(this)" ></td>
</tr>
<tr>
<td><INPUT id="hdState" type="hidden" name="hdState" runat="server"
value="off"></td>
</tr>
<tr>
<td>
<asp:Button id="btnPostBack " runat="server" Text="Server Button Post
Back"></asp:Button></td>
</tr>
</table>
</form>
</body>
</HTML>

=============co de behind========= ========
public class autorefresh : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Butt on btnPostBack;
protected System.Web.UI.H tmlControls.Htm lInputHidden hdState;

private void Page_Load(objec t sender, System.EventArg s e)
{
if(IsPostBack)
{
Response.Write( "<br>Page_L oad fired at: " +
DateTime.Now.To LongTimeString( ));

if(hdState.Valu e == "on")
{
Page.RegisterSt artupScript("in it_refresh","<s cript
language='javas cript'>document .getElementById ('btnControl'). click();</script
");

}
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}

private void InitializeCompo nent()
{
this.btnPostBac k.Click += new
System.EventHan dler(this.btnPo stBack_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void btnPostBack_Cli ck(object sender, System.EventArg s e)
{
Response.Write( "<br>Server Button is clicked at: " +
DateTime.Now.To LongTimeString( ));
}
}
=============== ===============

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 21 '05 #7
Hi Brian,

Thanks for your followup. Well, if you meet any further problem in the
furture or need any other assistance, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
12936
by: Scott | last post by:
I have a clickable graph that resides on page 1. If user clicks a data point on the graph, the page runs again yeilding a 2nd graph that shows a more detailed graph. Problem is, I have a recordset table on the 2nd graph page and because the user gets to it by clicking the graph, the page doesn't properly post to render the recordset table. I can click "Refresh" on 2nd page and table displays fine. Is there an ASP refresh command that...
1
34327
by: Lew | last post by:
Hi all, I'm trying to create a page that has a user-selectable page auto-refresh option (IE 5.5). Essentially, it's a page that contains a checkbox, when the user checks the checkbox, I'd like the page to auto-refresh every 4 seconds....if the user un-checks the checkbox, I'd like to turn off the auto refresh. The page is as follows:
0
1993
by: Marcus | last post by:
Hello! I'm buildning a webpage in ASP.NET using Visual Basic. The page contains a datagrid, a dropdownlist, some textboxes and a couple of buttons. The datagrid displays barcodes from a table in a database (Sql Server 2000). I want to automatic update the datagrid when new new posts arrives in the table. Before the datagird is updated, the choosen index from the
3
2084
by: Ronald S. Cook | last post by:
I want to have a web page that shows the first 10 records of data. I want it to wait 10 seconds and then show then next 10 records. How can I do this? This is for events like what you'd see on a digital sign in a hotel lobby. Thanks, Ron
10
32905
by: phforum | last post by:
Hi, I wrote a PHP page for user input the information to search the database. And the database data will update every second. I want to set the auto refresh to get the data from database every minute. But the page always display the dialog box ask me to resend the information. How to disable this warning message. I using POST and REQUEST to get the data from user input page. Thanks all
3
9372
by: tinuananster | last post by:
Hi, I need to auto refresh a page after a specific time interval. When the page is accessed the first time, a request parameter is null and hence it gets redirected to a welcome page (static html). When user clicks on a link from the left menu, i take the ID passed during the click and the page is redirected to a jsp that has information specific to that ID. Now, when i write a script to refresh this page (with some info), the ID is lost and...
2
5824
by: ankitmathur | last post by:
Hi Fellow Members, I want to know if HTML provides any way of refreshing a page only once automatically. My requirement is to refresh a page automatically only once after 2 minutes to display an updated data. Henceforth, the page should not refresh anymore. Can anyone suggest me some ways to do it.
2
2925
by: =?Utf-8?B?QW1pciBUb2hpZGk=?= | last post by:
Hi I have a web page that has a TreeView on it. If I DONT'T expand the TreeView nodes, the auto refresh works nicely: my page gets refreshed every minute. As soon as I expand a node on the TreeView, the page stops auto-refreshing. Any ideas why this is happening? I have acheived auto refresh using the following:
3
9915
by: tvnaidu | last post by:
How to auto refresh page for every 3 minutes by passing command part of URL?. I need to refresh one page automatically by passing that refresh command part of url, for example if I want to refresh my-own-web-page.com: some URL like this to auto reload? http://www.my-own-web-page.com?auto-refresh=3
0
9879
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11348
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10540
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9727
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8099
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7249
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5938
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3359
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.