question about timer

Last post 10-02-2007 4:37 AM by Jin-Yu Yin - MSFT. 3 replies.

Sort Posts:

  • question about timer

    09-27-2007, 12:54 AM
    • Member
      24 point Member
    • sdevil
    • Member since 01-17-2007, 11:01 PM
    • Posts 53

    Hi there,

    I made a ajax tabcontainer with updatepanel and timer. the timer is running for change activetabindex every 30 seconds.

    Now i want to reset timer when user click tab from their explorer. otherwises if the timer running at 25 seconds and user click  to another tab, they want to write down something, they only got 5 seconds to do that.

    any idea i can do that?

    thanks

  • Re: question about timer

    09-27-2007, 5:23 AM
    • Star
      13,643 point Star
    • gt1329a
    • Member since 06-24-2002, 12:53 AM
    • Atlanta
    • Posts 2,252
    • TrustedFriends-MVPs

    You can use the OnClientActiveTabChanged event of the TabContainer to stop or reset your Timer when the tabs are changed manually.

    Also, you might consider handling those tab changes on the client side, instead of using the Timer.  Since all of the tabs are rendered and tab changes are just client side events, it's fairly inefficient to force partial postbacks every 30 seconds just to change the tab.  You can use setInterval or setTimeout to achieve the same result, without requiring postbacks.

    Encosia - ASP.NET, jQuery, AJAX, and more.

    Latest article: Emulate ASP.NET validation groups with jQuery validation
  • Re: question about timer

    09-27-2007, 6:18 AM
    • Member
      24 point Member
    • sdevil
    • Member since 01-17-2007, 11:01 PM
    • Posts 53

    Hi gt1329a,

    thanks replying my post. i will try onclientactivetabchanged event. but for your client side events i am not quite get your point.

    could you pls give me some code example for client side event? thanks

    best regards,

    martin

  • Re: question about timer

    10-02-2007, 4:37 AM
    Answer

    Hi,

    Do it like this:

    <ajaxToolkit:TabContainer ID="TabContainer1" runat="server" OnClientActiveTabChanged="resetTimer()">

    function resetTimer(){
         var b = $find(<%= Timer1.ClientID %>);
          if(b){
          b._stopTimer();
          b._startTimer();
          }
     }

    Best Regards,

    Sincerely,
    Jin-Yu Yin
    Microsoft Online Community Support
Page 1 of 1 (4 items)