Home > DeveloperSection > Forums > Two timers in one page
Simons Hood
Simons Hood

Total Post:70

Points:494
Posted on    December-16-2013 12:36 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 892  View(s)
Rate this:

I have two timers in one page but second timer is not working.

<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">

</asp:Timer>

<asp:Timer ID="Timer2" runat="server" Interval="5000" OnTick="Timer2_Tick">

</asp:Timer>

Code behind:

protected void Timer1_Tick(object sender, EventArgs e)

{

    lblcurrenttime5.Text = DateTime.Now.ToLongTimeString();

}      

protected void Timer2_Tick(object sender, EventArgs e)

{

    label6.Text = "Timer 2 is working";



Pravesh Singh

Total Post:411

Points:2881
Posted on    December-16-2013 12:53 AM

Hi Samuel,

Try putting the code you want in the pageLoad method

 protected void Page_Load(object sender, EventArgs e)

    {

      lblcurrenttime5.Text = DateTime.Now.ToLongTimeString();

      label6.Text = "Timer 2 is working";

    }

Since the page refreshes with the timer, it will pass through the pageload method.

Don't want to miss updates? Please click the below button!

Follow MindStick