.Net timer

I have a timer on my page that is disabled and the interval on the timer is 1000

I assume that's milliseconds?

On a click event I want to

Timer1.Enabled = True

run for 15 seconds

Timer1.Enabled = False
Who is Participating?
OSUKConnect With a Mentor Commented:
My suggestion would be...

In the Click event put the code
Timer1.Interval = 15000  'yes the time is in milliseconds

Open in new window

In the Timer1_Tick event..
'Add whatever code you wish to process

Open in new window

If you can include a bit more detail of what you are trying to achieve with the timer i could provide more detail.
Meir RivkinFull stack Software EngineerCommented:
add integer field in your class and set it to 0.
on the timer elapse event handler add 1 to the integer field each time.
also check if the field equals 15, if yes then stop the timer and set .Enabled = false, and reset the integer field to 0 again.
lrbristerAuthor Commented:
THis had example code and  got me going.
Thanks...it's working

I have this
    Protected Sub lnkFrustrated_Click(sender As Object, e As EventArgs) Handles lnkFrustrated.Click
        tmrFrustrated.Interval = "19000"
        imgFrustrated.Visible = True
        tmrFrustrated.Enabled = True

    End Sub

    Private Sub tmrFrustrated_Tick(sender As Object, e As System.EventArgs) Handles tmrFrustrated.Tick
        tmrFrustrated.Enabled = False
        imgFrustrated.Visible = False
        lblImage.Text = "Have a nice day!"
    End Sub
All Courses

From novice to tech pro — start learning today.