title: Timer and UpdatePanel in asp.net
body: <p>i'm trying to create a timer in asp.net</p>
  
  <pre><code>Public Class _Default
  Inherits System.Web.UI.Page
  Dim min As Integer
  Dim sec As Integer
  Dim hr As Integer
  Dim totalTime As Integer
  Dim timerStr As String
  
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      totalTime = 5340
      hr = Math.Floor(totalTime / 3600)
      min = 30
      sec = totalTime Mod 60
      timerStr = String.Format("{0:00}:{1:00}:{2:00}", hr, min, sec)
      label1.Text = timerStr
  End Sub
  
  
  Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs)
      Display()
      label1.Text = timerStr
  End Sub
  Protected Sub Display()
      totalTime -= 1
      hr = Math.Floor(totalTime / 3600)
      sec = totalTime Mod 60
      If sec = 0 Then
          min = (totalTime / 60) Mod 60
      End If
      timerStr = String.Format("{0:00}:{1:00}:{2:00}", hr, min, sec)
  End Sub
  
  Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
      Display()
      label1.Text = timerStr
  End Sub
  End Class
  </code></pre>
  
  <p>//update panel code</p>
  
  <pre><code>&lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
  &lt;/asp:ScriptManager&gt;
  &lt;asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick"&gt;
  &lt;/asp:Timer&gt;
  &lt;asp:Button ID="Button1" runat="server" Text="Button" /&gt;
  &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" 
      RenderMode="Inline"&gt;
      &lt;Triggers&gt;
          &lt;asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /&gt;
      &lt;/Triggers&gt;
       &lt;ContentTemplate&gt;
          &lt;asp:Label ID="label1" runat="server"&gt;&lt;/asp:Label&gt; 
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>now according to code timer call every second but its not happening i try same with button and click event but still text is not update but page refresh when i hit the button.Am i'm doing anything wrong?</p>