473,386 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1214
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.