?
Solved

I need to use a timer in my web app, are there any timer controls available or is there an easy way round this problem?

Posted on 2004-09-29
10
Medium Priority
?
209 Views
Last Modified: 2010-04-23
I need to time an exam.

At the start of the exam I must give the candidates 10 minutes to answer 10 questions.

The timer must be visible to the user.

If the timer ticks down to zero, I must be able to program something to happen by this event.

Your help would be much appreciated.

Regards

PG
0
Comment
Question by:pgilfeather
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 14

Expert Comment

by:dfu23
ID: 12180594
You could start with something like

<script type="text/javascript">
    var i = 0;
    window.onload = function() {
        window.setInterval("endExam()", 1000);
    };
    function endExam() {
        i++;
        if (i == 600) { // 600 seconds is 10 minutes
            document.location.href = "timesUp.htm";
        }
    }
</script>
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12180666
 Public m_Timer As System.Timers.Timer

  AddHandler m_Timer.Elapsed, AddressOf TimerTick

  Private Sub TimerTick(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)

  End Sub

Bob
0
 

Author Comment

by:pgilfeather
ID: 12180677
How would I put this in my .aspx page.

Do I treat the script part as I would a piece of VB.NET?

and what about the display?

Im not really very sure when it comes to javascript but I know for this kind of feature I really do need to get into a bit of it.

Could you explain a bit further on the code you have supplied.

Thanks very much, I really do appreciate it.

PG
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 96

Accepted Solution

by:
Bob Learned earned 1500 total points
ID: 12180705
Do you need a display?


In the code-behind page:

Public m_Timer As System.Timers.Timer = New System.Timers.Timer

 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here

    AddHandler m_Timer.Elapsed, AddressOf TimerTick

  End Sub

  Private Sub TimerTick(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)

  End Sub

Bob
0
 

Author Comment

by:pgilfeather
ID: 12180711
TheLearnedOne,
could you explain further please?

I am a beginner at this.

cheers

PG
0
 
LVL 14

Expert Comment

by:dfu23
ID: 12180730
Ok, basically Javascript is sent with the HTML that is sent to your clients machine ... it is then parsed and run on their machine ...

You should place the <script> tags in between the <head> tags of your document. As far as displaying the time ... how do you want to do it? something that displays text like "10:00" and then ticks down every second ... "9:59", "9:58" etc ... ? or something different?

And then, what needs to happen when it reaches "0:00"? Submit the exam even if they are not done? Or just navigate to another page?
0
 

Author Comment

by:pgilfeather
ID: 12180753
You have explained what I want to do exactly.

How can I accomplish this?

PG
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12180759
What do you need explained?

(1) Define a timer variable at the top of the module, above the Page_Load event.

(2) Add an event handler to the variable in the Page_Load event

(3) Set the interval (milliseconds) in the Page_Load event:  m_Timer.Interval = 1000 * 60 * 10  ' 10 minutes.

(3) Add the Timer_Tick event sink below the Page_Load event.  The event handler needs the signature as shown.

Open the web page, view the code behind page, and paste this code into the places indicated.

Bob
0
 

Author Comment

by:pgilfeather
ID: 12180809
"9:59", "9:58" etc ... this will do me
0
 

Author Comment

by:pgilfeather
ID: 12180902
TheLearnedOne,

yes, I need a display.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question