Link to home
Start Free TrialLog in
Avatar of Piyu75
Piyu75

asked on

Using timer control in a web form

I am beginner in VB.NET programming and need help in using timer control to display current time on my web form with in an accuracy of 1 second. I have put a timer control in design and making it enabled at run time on a button click. Setting a lable text in _Elapsed event of timer  to display the time. But it does not display anything. I have checked in debug mode that timer gets enabled but does not tgo to _Elapsed event. Any suggesttions ?
Private Sub ButMonitor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButMonitor.Click
        DBConnect = Session("DBConnect")
        TmrScan.Interval = 1000
        TmrScan.Enabled = True  
End Sub

Private Sub TmrScan_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles TmrScan.Elapsed
        LblTime.Text = TimeOfDay
End Sub
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

I would instead use JavaScript to do this as the timer would require a postback ...

http://www.javascript-page.com/clock.html
I agree...javascript is the way to go. If you want to use an asp.net timer control (which use javascript anyway) you can find a good one here:

http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=69a7c7bb-939a-4777-aceb-2d9ebbe35b85
Avatar of Piyu75
Piyu75

ASKER

Thanks guys ! I used javascript and timer and it worked well. But I need to use Timer Control in my  web form for other reasons also. I have to periodically check something in my database and if returned record match with failure criteria I have to post a comment on the web form otherwise checking continues on the server and does not post anything on the web form. Any suggestions please
http://www.silkwebware.net/products/details.aspx?id=9dc1eacf-db1b-479c-88f2-26aad4314d75

This a component that is event based and you could make calls to your db on intervals...
Avatar of Piyu75

ASKER

I do not have webtimer in my tool box and I wanna do it for free. Do you know any place where I can find something similar for free ?
ASKER CERTIFIED SOLUTION
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Piyu75

ASKER

Can't I use Server based timer ? I am trying to build one with no luck.
Avatar of Piyu75

ASKER

I will try this one. thanks guys for being patient with a biginner like me. I will let you know.
Avatar of Piyu75

ASKER

I used a server based timer to write data to access db and posting back my page thru meta tag. On page load it retrievs the latest record from db. for now that works well but I am sure that these timers will cause interference if Server based timer is trying to write data and at the same time postback occurs because of meta tag which will try to oprn the same access db for reading data. Wont it ?