469,616 Members | 1,720 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,616 developers. It's quick & easy.

Timer doesnt work

Hi,
Im trying to make a page which refreshes by itself.For that i have added a timer
with following properties:
Autoreset = true
Enabled = true
interval = 30000
Name = timer1
on timer1_elapsed i have added the following code:
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As _
System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed

Label2.Text = "time is: " + Now.ToString

End Sub

But this does not result in label showing current time after its been loaded.
Any idea why? Also how can i make it work?
Thanks
vickeybird
Nov 18 '05 #1
3 1115
check out the posting "Refreshing a page programatically" 02/04/2004

or use this within your html tags
<head>
<META HTTP-EQUIV="Refresh" CONTENT="15">
</head>

content relates to the number of seconds

ian

"vickey" <vi********@yahoo.com> wrote in message
news:f7**************************@posting.google.c om...
Hi,
Im trying to make a page which refreshes by itself.For that i have added a timer with following properties:
Autoreset = true
Enabled = true
interval = 30000
Name = timer1
on timer1_elapsed i have added the following code:
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As _
System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed

Label2.Text = "time is: " + Now.ToString

End Sub

But this does not result in label showing current time after its been loaded. Any idea why? Also how can i make it work?
Thanks
vickeybird

Nov 18 '05 #2
Once the page is served, it doesn't exist any more server side. You'll have
to do this client side. For example using
http://www.submitcorner.com/Guide/Meta/refresh.shtml

Patrice

"vickey" <vi********@yahoo.com> a écrit dans le message de
news:f7**************************@posting.google.c om...
Hi,
Im trying to make a page which refreshes by itself.For that i have added a timer with following properties:
Autoreset = true
Enabled = true
interval = 30000
Name = timer1
on timer1_elapsed i have added the following code:
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As _
System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed

Label2.Text = "time is: " + Now.ToString

End Sub

But this does not result in label showing current time after its been loaded. Any idea why? Also how can i make it work?
Thanks
vickeybird

Nov 18 '05 #3
You're mixing up server-side and client-side here. An ASP.Net Page has two
different and separate parts to it. One is the server-side code that
generates the HTML in the other, which is the client-side document. Your
code is server-side code. The server-side class lives for a matter of
milliseconds, long enough to generate the HTML that is sent to the browser.
Your timer will never fire. What I would suggest is doing the same thing,
but on the client-side, using JavaScript.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"vickey" <vi********@yahoo.com> wrote in message
news:f7**************************@posting.google.c om...
Hi,
Im trying to make a page which refreshes by itself.For that i have added a timer with following properties:
Autoreset = true
Enabled = true
interval = 30000
Name = timer1
on timer1_elapsed i have added the following code:
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As _
System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed

Label2.Text = "time is: " + Now.ToString

End Sub

But this does not result in label showing current time after its been loaded. Any idea why? Also how can i make it work?
Thanks
vickeybird

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Alvo von Cossel I | last post: by
3 posts views Thread by vickey | last post: by
6 posts views Thread by Antti Laakso | last post: by
5 posts views Thread by csgraham74 | last post: by
2 posts views Thread by John David Thornton | last post: by
17 posts views Thread by Ratnesh Raval | last post: by
8 posts views Thread by =?Utf-8?B?RGF2ZSBCb29rZXI=?= | last post: by
1 post views Thread by javalearner123 | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.