PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 1.00 average.

auto refresh web page

 
 
=?Utf-8?B?QnJpYW4=?=
Guest
Posts: n/a
 
      27th Oct 2004
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UnVsaW4gSG9uZw==?=
Guest
Posts: n/a
 
      27th Oct 2004
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Me.CheckBox1.Checked Then
Context.Response.AddHeader("REFRESH", "2")
End If
End Sub

Set CheckBox1.AutoPostBack= 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

 
Reply With Quote
 
=?Utf-8?B?Sm9yZ2UgU2VycmFubyBbTVZQIFZCXQ==?=
Guest
Posts: n/a
 
      27th Oct 2004
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

 
Reply With Quote
 
=?Utf-8?B?Sm9yZ2UgU2VycmFubyBbTVZQIFZCXQ==?=
Guest
Posts: n/a
 
      27th Oct 2004
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

 
Reply With Quote
 
=?Utf-8?B?QnJpYW4=?=
Guest
Posts: n/a
 
      28th Oct 2004
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

 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      29th Oct 2004
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.setInterval()" and "document.forms[0].submit()" to autopost the
page. And since the
"window.setInterval()" 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>autorefresh</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
var tid;



function ControlRefresh(btn)
{
var hd = document.getElementById("hdState");
if(btn.value == "Start")
{
tid = window.setInterval("AutoRefresh()",3000);
btn.value = "Stop";
hd.value = "on";
}
else
{
window.clearInterval(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="ControlRefresh(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>

=============code behind=================
public class autorefresh : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnPostBack;
protected System.Web.UI.HtmlControls.HtmlInputHidden hdState;

private void Page_Load(object sender, System.EventArgs e)
{
if(IsPostBack)
{
Response.Write("<br>Page_Load fired at: " +
DateTime.Now.ToLongTimeString());

if(hdState.Value == "on")
{
Page.RegisterStartupScript("init_refresh","<script
language='javascript'>document.getElementById('btnControl').click();</script
>");

}
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.btnPostBack.Click += new
System.EventHandler(this.btnPostBack_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btnPostBack_Click(object sender, System.EventArgs e)
{
Response.Write("<br>Server Button is clicked at: " +
DateTime.Now.ToLongTimeString());
}
}
==============================

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


 
Reply With Quote
 
=?Utf-8?B?QnJpYW4=?=
Guest
Posts: n/a
 
      29th Oct 2004
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.setInterval()" and "document.forms[0].submit()" to autopost the
> page. And since the
> "window.setInterval()" 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>autorefresh</title>
> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
> <meta name="CODE_LANGUAGE" Content="C#">
> <meta name="vs_defaultClientScript" content="JavaScript">
> <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
> <script language="javascript">
> var tid;
>
>
>
> function ControlRefresh(btn)
> {
> var hd = document.getElementById("hdState");
> if(btn.value == "Start")
> {
> tid = window.setInterval("AutoRefresh()",3000);
> btn.value = "Stop";
> hd.value = "on";
> }
> else
> {
> window.clearInterval(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="ControlRefresh(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>
>
> =============code behind=================
> public class autorefresh : System.Web.UI.Page
> {
> protected System.Web.UI.WebControls.Button btnPostBack;
> protected System.Web.UI.HtmlControls.HtmlInputHidden hdState;
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> if(IsPostBack)
> {
> Response.Write("<br>Page_Load fired at: " +
> DateTime.Now.ToLongTimeString());
>
> if(hdState.Value == "on")
> {
> Page.RegisterStartupScript("init_refresh","<script
> language='javascript'>document.getElementById('btnControl').click();</script
> >");

> }
> }
> }
>
> #region Web Form Designer generated code
> override protected void OnInit(EventArgs e)
> {
> InitializeComponent();
> base.OnInit(e);
> }
>
> private void InitializeComponent()
> {
> this.btnPostBack.Click += new
> System.EventHandler(this.btnPostBack_Click);
> this.Load += new System.EventHandler(this.Page_Load);
>
> }
> #endregion
>
> private void btnPostBack_Click(object sender, System.EventArgs e)
> {
> Response.Write("<br>Server Button is clicked at: " +
> DateTime.Now.ToLongTimeString());
> }
> }
> ==============================
>
> 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.)
>
>
>

 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      1st Nov 2004
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.)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How auto refresh page but with new data? Ronald S. Cook Microsoft ASP .NET 3 30th Apr 2006 07:33 PM
Auto save web page on refresh zmaki Freeware 0 19th Apr 2006 10:25 AM
auto page update/refresh? johnw100@mickeyfan.com Microsoft Frontpage 1 18th Sep 2005 12:56 PM
web page auto refresh =?Utf-8?B?ZXJpYzc3NTM=?= Microsoft Frontpage 2 13th Sep 2005 02:39 PM
RE: auto refresh page or frame Marcus Malmgren Microsoft ASP .NET 0 2nd Apr 2004 08:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:04 AM.