Showing posts with label seconds. Show all posts
Showing posts with label seconds. Show all posts

Wednesday, March 21, 2012

question about timer

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

You can use theOnClientActiveTabChanged 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.


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


Hi,

Do it like this:

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

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

Best Regards,

Question about updatepanel

Hi,
I got a problem about update panel.
My scenario is that:
I have two tasks, each of which is triggered by buttons..
"A" needs 10 seconds to complete, and "B" needs 2 seconds.
After clicking A button, the user click B within 10 seconds.
Normally the program will stop doing A and start doing B, right?
But once I use the UpdatePanel, it just keep doing A and doesn't do B.
WHY?

Here is my example code:

<body> <form id="form1" runat="server"> <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True"/> <asp:Button ID="ButtonA" runat="server" Text="intensive task" /> <asp:Button ID="ButtonB" runat="server" Text="interrupt task" />  <asp:Label ID="Label2" runat="server" /> <atlas:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label1" runat="server" /l> </ContentTemplate> <Triggers> <atlas:ControlEventTrigger ControlID="ButtonA" EventName="Click" /> </Triggers> </atlas:UpdatePanel> <atlas:UpdateProgress ID="UpdateProgress1" runat="server"> <ProgressTemplate> Processing... </ProgressTemplate> </atlas:UpdateProgress> </form> </body>
Protected Sub ButtonA_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles ButtonA.Click System.Threading.Thread.Sleep(10000) Label1.Text ="Intensive task suceeded!!"End Sub Protected Sub ButtonB_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles ButtonB.Click Label2.Text ="Interrupted task succeeded!!"End Sub
I need the normal function, that is to stop A and do B when clicking ButtonB, and also the function of partial refreshing. Any ideas?Could anyone give me some suggestion?