473,473 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1216
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Anders | last post by:
Hi all, I have two classes: Form1 and GrabTitle Form1 instantiates GrabTitle In GrabTitle there is a Timer event which calls several events in Form1. The strange thing is that one event...
3
by: Alvo von Cossel I | last post by:
hi, i have a form that stays on the screen for 300 milliseconds and then closes. straight after this, another form opens. that works but after that, the second one closes. someone suggested that...
3
by: vickey | last post by:
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...
6
by: Antti Laakso | last post by:
Hi i have function like above Public Sub halytystutkinta() Dim ds As New DataSet ds = dl2.HaeHalytys() Dim onkohal As Int16 onkohal = ds.Tables(0).Rows(0).Item("onkohalytys") halid =...
5
by: csgraham74 | last post by:
HI all, I want to implement this scenario: I need my ASP.NET website to check a SQL table every 30 seconds and if there is a change to display a message to user. I have created a panel control...
2
by: Sam Miller | last post by:
Normally the debugger (visual studio .net environment) is good at pointing out the line of code that caused an exception.... except when that code is executed as part of a timer handler. In the...
2
by: John David Thornton | last post by:
I've got a Windows Service class, and I put a System.Threading.Timer, and I've coded it as shown below. However, when I install the service and then start it in MMC, I get a peculiar message: ...
17
by: Ratnesh Raval | last post by:
hi all, i m having some problem in timer control. sub timer.tick() timer.stop() do...something timer.enabled = true end sub
8
by: =?Utf-8?B?RGF2ZSBCb29rZXI=?= | last post by:
I have a Timer that I set to go off once a day, but it frequently fails! In order to debug I would like to be able to check, at any moment, whether the Timer is enabled and when it will next...
1
by: javalearner123 | last post by:
hey i need help. ive been trying to put a timer in a for loop, but it doesnt seem to work. need help. thanx. i want the data printed in every array to be delayed by a few seconds heres the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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,...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.