I have a timer and and updatepanel on a page. A user enters some data and clicks a button to activate the timer. I have set the timer tick interval to 1000 (1 second). On the timer tick event (vb.net codebehine) I have an Insert into my DB that happends
if a response is received from another process. My issue is the the insert into the DB is sometimes being repeated. In my timer tick event code I have set the timer.enabled to false, so it will not tick again.
Is it possible that the timer.enabled property is not getting set to false before another tick happens?
'check if we have received a response from the server.
If stuff.CheckResponse() Then
If stuff.ResponseCode = "000" Then
'Turn off timer so it will not tick again
Timer1.Enabled = False
'Do Insert into DB
Jackxxx
Contributor
3060 Points
2788 Posts
Timer and Updatepanel Issue
Mar 02, 2012 05:57 PM|LINK
I have a timer and and updatepanel on a page. A user enters some data and clicks a button to activate the timer. I have set the timer tick interval to 1000 (1 second). On the timer tick event (vb.net codebehine) I have an Insert into my DB that happends if a response is received from another process. My issue is the the insert into the DB is sometimes being repeated. In my timer tick event code I have set the timer.enabled to false, so it will not tick again.
Is it possible that the timer.enabled property is not getting set to false before another tick happens?
Any suggestions are appreciated!
Sample of timer and updatepanel markup
<table> <tr> <td> <div> <asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="1000" Enabled="false"> </asp:Timer> </div> <asp:UpdatePanel ID="UpdatePanel3" UpdateMode="Conditional" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> <ContentTemplate> <asp:Label ID="lblResponse" runat="server" Text=""></asp:Label> </ContentTemplate> </asp:UpdatePanel> </td> </tr> </table>'check if we have received a response from the server. If stuff.CheckResponse() Then If stuff.ResponseCode = "000" Then 'Turn off timer so it will not tick again Timer1.Enabled = False 'Do Insert into DBJackxxx
Primillo
Star
8727 Points
1679 Posts
Re: Timer and Updatepanel Issue
Mar 03, 2012 07:21 AM|LINK
You may check if the record exist in the database, if exist then don't do the insert
Primillo
http://www.facebook.com/programandopuntonet