c# - Multiple ASP timer not working under single update panel -


i have implement clock , 15 mins countdown ticker on aspx page. please not suggest me client side scripts not in requirement , knew load generating on server using asp ticker , update panel... knew flaws client requirements.

aspx/html:

  <asp:scriptmanager runat="server" id="scr"/>         <asp:updatepanel runat="server" id="up" updatemode="conditional" >              <contenttemplate>                  <asp:timer runat="server" id="timer1" ontick="timer1_ontick" interval="1000"></asp:timer>                   <label id="lbltime" runat="server"></label>                   <asp:timer runat="server" id="timer2" ontick="timer2_ontick" interval="1000"></asp:timer>                   <label id="label1" runat="server"></label>              </contenttemplate>             <triggers>                 <asp:asyncpostbacktrigger controlid="timer1" eventname="tick"/>                 <asp:asyncpostbacktrigger controlid="timer2" eventname="tick"/>              </triggers>         </asp:updatepanel> 

codebehind:

 protected void timer1_ontick(object sender, eventargs e)         {             timezoneinfo tzi = timezoneinfo.findsystemtimezonebyid("india standard time");             datetime indiantime = timezoneinfo.converttimefromutc(datetime.utcnow, tzi);             lbltime.innertext = string.format("{0:dd:mm:yyyy hh:mm:ss}", indiantime);          }           protected void timer2_ontick(object sender, eventargs e)         {             var ts = new timespan(0, 14, 59);             var onesecond = new timespan(0, 0, 1);             ts = ts.subtract(onesecond);             label1.innertext = string.format("{0}:{1}", ts.minutes, ts.seconds);         } 

problem:

my first 1 working fine countdown timer doesnot work. either displays nothing or static text 14:58. please note, have tried 2 different update panels . no success. suggestions using multiple update panels welcome. no issues that. kindly help.

updated code

still no effect. thread unsafe ??? think 1 thread stomping another. please help

timespan  ts ;  timespan onesec ;   protected void page_load(object sender, eventargs e) {     if (!ispostback)     {         ts = new timespan(0, 15, 0);         onesec = new timespan(0, 0, 1);     } } protected void timer1_tick(object sender, eventargs e) {     lbl1.text = string.format("{0:dd.mm.yyyy hh:mm:ss}", datetime.now);     ts = ts.subtract(onesec);     lbl2.text = string.format(@"{0:hh\:mm\:ss}", ts); }` 


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -