Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to implement count down timer in asp.net using vb
    text
    copied!<p><strong>Default.aspx</strong></p> <pre><code>&lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt; &lt;ContentTemplate&gt; &lt;asp:Label ID="Label1" runat="server"&gt;2:00:00&lt;/asp:Label&gt; &lt;asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick"&gt; &lt;/asp:Timer&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p><strong>Default.aspx.vb</strong></p> <pre><code>Dim timer, timer_arr() As String timer = Label1.Text timer_arr = timer.Split(":") Dim seconds = Integer.Parse(timer_arr(2)) Dim minutes = Integer.Parse(timer_arr(1)) Dim hours = Integer.Parse(timer_arr(0)) If seconds = 0 And minutes = 0 And hours = 0 Then Timer1.Enabled = False Else seconds = seconds - 1 End If If (seconds &lt; 0) Then seconds = 59 minutes = minutes - 1 End If If minutes &lt; 0 Then minutes = 59 hours = hours - 1 End If Label1.Text = hours &amp; ":" &amp; minutes &amp; ":" &amp; seconds </code></pre> <p>The above code showing the expected result, i mean, i need the count down timer, which will display the countdown timer to the client like <code>2:45:34</code>. But the problem is the value of seconds is decreasing by twice. i mean after <code>2:45:34</code> in the next second instead of displaying <code>2:45:33</code>, it displaying <code>2:45:32</code> and so on. I'm very confused, from my point of view, everything is all right. Need help !! </p> <p><strong>UPDATED</strong></p> <p>I believe, client side scripting i.e. javascript will be the another option, but i need the timer for online exam system, which means timer should continue ticking whenever client send the request to the server. But, if i will use javascript then timer value will interrupted and will show unexpected value i.e. may be initialized again, and other cause. So, i believe server side scripting will be the best. If anyone have other suggestion, then i will appreciate. !! </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload