Timer doesnt work

V

vickey

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
 
I

Ian Oldbury

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
 
K

Kevin Spencer

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top