0

On selection change of radio button, I want to show a clock/timer for 5 minutes and set a lock in DB.

Once 5 minutes are over, I have to remove the lock.

Also in case the browser window has been closed or redirected to other page, I should remove the lock.

Any pointers on how to achieve this functionality?

Are there any built-in clocks/timers ?

Thanks in Advance.

RMN
  • 754
  • 9
  • 25
  • 45
  • 1
    Do not do this in javascript. What are you going to do in case of disconnected client (network issues)? Or in case of power failure on client side? Or in case of browser crash? – Artem Mar 13 '12 at 15:02
  • Artem, Good point. I am also planning to keep a job running to clear the lock after regular intervals. – RMN Mar 13 '12 at 18:27

2 Answers2

2

I would use jQuery to wire up the click() handler, and you can use the setTimeout() method to call a function after 5 minutes

setTimeout(function() { /* your ajax call here */ }, 5000); 

For more information on detecting when the browser closes, see this question:

javascript detect browser close tab/close browser

Community
  • 1
  • 1
mgnoonan
  • 7,060
  • 5
  • 24
  • 27
0

Used an asp:timer control instead.

RMN
  • 754
  • 9
  • 25
  • 45