By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,342 Members | 1,171 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,342 IT Pros & Developers. It's quick & easy.

Timer doesnt work

P: n/a
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
Share this Question
Share on Google+
3 Replies

P: n/a
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

P: n/a
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

P: n/a
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.