Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,
I am developing an on line test application. All test are timed. Duration is 60 minutes.. I want to implement countdown time which decreases by seconds. Somewhere on my page time remaining should be displayed. Like 59:59, 59:58, 59:57... After 60 mins is over the test should automatically be submitted. Before 60 mins also we can also submit the test.
Posted
Updated 23-Jul-16 9:14am
v2
Comments
Sergey Alexandrovich Kryukov 2-Jan-12 1:42am    
It depends on what do you want to do with it. Please, a bit more detail. Use "Improve question" above.
--SA

You can use Timer Control by using ajax controls


ASP.NET
    <asp:timer id="Timer1" runat="server" interval="1000" ontick="Timer1_Tick" xmlns:asp="#unknown"></asp:timer>
<asp:lable id="Lable1" runat="server" xmlns:asp="#unknown" />


Add ontick event code in cs file:

C#
protected void Timer1_Tick(object sender, EventArgs e)
       {
            int seconds;
           if (Convert.ToString(Label1.Text) != "")
           {
               seconds = int.Parse(Label1.Text);
           }
           else
           {
               seconds =Convert.ToInt32(defaultTimer);//set some time count in default timer
           }
           Session[timeout"] = (seconds - 1).ToString();
           if (seconds> 0)
           {

               Label1.Text = (seconds - 1).ToString();

           }
           else
           {
               Timer1.Enabled = false;
               
           }
       }
 
Share this answer
 
v2
Go through the link for Countdown timer using Java Script

Here[^]
 
Share this answer
 
you can use timer control (ajax extension control)

ASP.NET
<asp:timer xmlns:asp="#unknown">
       ID="Timer1" runat="server" Interval="1000" >
   </asp:timer>
 
Share this answer
 
 
Share this answer
 
 
Share this answer
 
ASP.NET
<div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick1">
    </asp:Timer>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <Triggers>
           <asp:AsyncPostBackTrigger ControlID="Timer1" />
        </Triggers>
        
        
        <ContentTemplate>
            
            <asp:Label ID="lbl" runat="server" Font-Names="Verdana" ForeColor="Black" Font-Bold="True"></asp:Label>
            <br />
        </ContentTemplate>
    </asp:UpdatePanel>
</div>
 
Share this answer
 
Comments
Dave Kreskowiak 23-Jul-16 15:23pm    
Do NOT post answers to FOUR YEAR OLD questions.

On top of that, your "solution" posts back to the web server once a second. It's highly inefficient to say the least.
joh meerholz 29-Nov-17 5:51am    
shot!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900