Click here to monitor SSC

countdown timer in ASP.NET

Last post 11-05-2011, 3:14 AM by helit. 17 replies.
Page 1 of 2 (18 items)   1 2 Next >
Sort Posts: Previous Next
  •  03-07-2007, 1:24 AM Post number 20134

    countdown timer in ASP.NET

    Hi all,

    I need to display the countdown timer for the purpose of online quiz.

    Give me the solution on this post.

     


    am in my way
  •  03-07-2007, 10:04 PM Post number 20303 in reply to post number 20134

    • Damon is not online. Last active: 02-07-2012, 10:24 AM Damon
    • Top 10 Contributor
    • Joined on 06-26-2006
    • Dallas, TX
    • Atari ST

    Re: countdown timer in ASP.NET

    I see two options for you.

    1.) Use a client-script based timer and just submit the completed portion of the test whe the timer runs out.  Here's an example:

    http://www.javascript-page.com/timer.html

    Of course, this approach brings with it the possibility of the user jacking with your javascript and giving themselves more time than is normally alloted.  Depending on who you are resting and their technical savvy, this may be an issue.

    2.) Set an absolute time on the server that identifies the last possible time when a user can submit their answers.  Then submit the user's data periodically using an ajax call and check the current time against the absolute time to see if the users updated information was submitted in a valid time period.  This would eliminate someone's ability to give themselves additional time, but it is a more technical solution. 

    - Damon


    Damon Armstrong, Technology Consultant
    [Blog] [Articles]
  •  03-07-2007, 10:40 PM Post number 20306 in reply to post number 20303

    Re: countdown timer in ASP.NET

    Hi

    I have used the same scenario of my script, but the time will be changing randomly. While clicking on any in aspx page the time will be changing at the moment, So i have one hidden field in aspx page and  I have assigned the time value in particular hidden field, but it throw this exception "Object reference not set to an instance of an object".

    I have assigned the hidden field value in codebehind:

    hidfield.Value=Cstr(10)  'hidfield is hidden field

    but it is not working. If any other method to assign value in hidden field.


    am in my way
  •  03-07-2007, 10:43 PM Post number 20307 in reply to post number 20306

    • Damon is not online. Last active: 02-07-2012, 10:24 AM Damon
    • Top 10 Contributor
    • Joined on 06-26-2006
    • Dallas, TX
    • Atari ST

    Re: countdown timer in ASP.NET

    That's how you assign the value, but the page is apparently not finding the hidfield control.  You're getting an object reference error when you attempt to access the Value field from the hidField object because the hidField is NOT referencing an actual object.  If it was, then your assignment should work.

    It is an ASP.NET control, correct?  Like <asp:HiddenField runat="server" id="hidField" /> ?


    Damon Armstrong, Technology Consultant
    [Blog] [Articles]
  •  03-07-2007, 10:48 PM Post number 20310 in reply to post number 20307

    • Damon is not online. Last active: 02-07-2012, 10:24 AM Damon
    • Top 10 Contributor
    • Joined on 06-26-2006
    • Dallas, TX
    • Atari ST

    Re: countdown timer in ASP.NET

    "I have assigned the value in properties window it accessed but i need to change the value randomly. Thats my problem."

    What do you mean you need to change it randomly?  There's got to be some structure behind when it changes.  Also, are you using this field on a single page, or are you trying to use it across multiple pages?

    Damon Armstrong, Technology Consultant
    [Blog] [Articles]
  •  03-07-2007, 10:52 PM Post number 20311 in reply to post number 20307

    Re: countdown timer in ASP.NET

    No that is html control.

    <INPUT id="hidfield" style="Z-INDEX: 101; LEFT: 344px; POSITION: absolute; TOP: 48px" type="hidden" value="">  This is folowing tag.

    above i have assigned the value directly it is accessed but through code behind it is not accessing.


    am in my way
  •  03-07-2007, 11:01 PM Post number 20312 in reply to post number 20310

    Re: countdown timer in ASP.NET

    I have used in single page.

    This is complete scenario:

    I have conduct one quiz program in online. That quiz have 10 questions, each question have duration 1 minute or 2 minutes,  totaly 10 minutes. but the question displaying one by one. when user attends the first question clicking on next button the new question displaying, at the same time particular question time also displaying. suppose i have assigned particular question time 1 minute, if time is expired automatically next question displaying.


    am in my way
  •  03-07-2007, 11:01 PM Post number 20313 in reply to post number 20311

    • Damon is not online. Last active: 02-07-2012, 10:24 AM Damon
    • Top 10 Contributor
    • Joined on 06-26-2006
    • Dallas, TX
    • Atari ST

    Re: countdown timer in ASP.NET

    You cannot access HTML from your code behind unless your tag has been marked with Runat=server.  So, you can do any of the following

    1.) Add a runat=server tag and see if you can set the value in your code behind

    2.) Use the <asp:HiddenField> control so you can access the item from your code behind

    3.) Use inline script to set the value using a property from your page, e.g.
    <INPUT id="hidfield" type="hidden" value="<%=HiddenTimeValueProperty%>">

    Also know, however, that if you are moving from one page to another page, the hidden field is NOT going to automatically follow from one page to the next. If you are staying on the same page, you should be good to go automatically.


    Damon Armstrong, Technology Consultant
    [Blog] [Articles]
  •  03-07-2007, 11:28 PM Post number 20315 in reply to post number 20313

    Re: countdown timer in ASP.NET

    I am trying to your suggestion. after that i will let you know.

    I appreciate your help...


    am in my way
  •  03-08-2007, 12:35 AM Post number 20318 in reply to post number 20315

    Re: countdown timer in ASP.NET

    I got the solution. I am using this method.

    <%
      Dim TimeVal As String=Session("Time")
      %>
    <INPUT id="hidfield" type="hidden" value="<%=TimeVal%>"></CENTER>

    the above lines in inline coding.

    In code behind

    Session("Time")=1

    so this value to pass the inline coding.

    Thankz damon....

     

     

     

     


    am in my way
  •  03-08-2007, 4:21 AM Post number 20326 in reply to post number 20318

    Re: countdown timer in ASP.NET

    Hi again

    I have one method in code behind named as countquestion(), how can i call this method from java script.

    If any idea.


    am in my way
  •  03-08-2007, 9:04 AM Post number 20333 in reply to post number 20326

    • Damon is not online. Last active: 02-07-2012, 10:24 AM Damon
    • Top 10 Contributor
    • Joined on 06-26-2006
    • Dallas, TX
    • Atari ST

    Re: countdown timer in ASP.NET

    You need to implement a client-side callback.  Check out the following article.

    http://www.dotnetjunkies.com/Article/E80EC96F-1C32-4855-85AE-9E30EECF13D7.dcik


    Damon Armstrong, Technology Consultant
    [Blog] [Articles]
  •  03-08-2007, 11:49 PM Post number 20371 in reply to post number 20333

    Re: countdown timer in ASP.NET

    hi

    I have call codebehind method like <%QuestionAdd()%>, but it is not firing. also use this   method        <%=QuestionAdd%>, but not firing what to do.


    am in my way
  •  03-09-2007, 9:26 AM Post number 20413 in reply to post number 20371

    • Damon is not online. Last active: 02-07-2012, 10:24 AM Damon
    • Top 10 Contributor
    • Joined on 06-26-2006
    • Dallas, TX
    • Atari ST

    Re: countdown timer in ASP.NET

    What does the QuestionAdd() method do exactly?  Does it return a string?  Does it add controls to the page?

    If you are trying to modify control on the page, then you need to call the method from your code behind, not as inline script. 

    For the most part, you don't want to use the inline script on your web page, you want to use the code-behind model.  So you should be calling QuestionAdd from inside your code behind, and it should do something to modify the controls on the page.


    Damon Armstrong, Technology Consultant
    [Blog] [Articles]
  •  03-09-2007, 11:46 PM Post number 20441 in reply to post number 20413

    Re: countdown timer in ASP.NET

    "QuestionAdd()" function doesnot return any value. This function main theme to select the next question and display that question in same page "quiz.aspx".

    the next question displaying 3 ways.

    1) user clicking on next button. This is server control.

    2)user clicking on skip button. This is server control.

    3) current question duration is over automatically displaying the next question. so when the countdown timer reached at 00:00, the question time is over so it displaying next question. Here I need to call the "QuestionAdd()" method.

     


    am in my way
Page 1 of 2 (18 items)   1 2 Next >
View as RSS news feed in XML