Better timeout mechanism?

Discussion in 'ASP .Net' started by MattB, Aug 30, 2006.

  1. MattB

    MattB Guest

    I'm using the old html method of creating timeouts for my asp.net (1.1)
    pages. This apparently isn't working as well as I'd hoped because it
    takes a postback to reset the timer. I've had complaints of people
    typing into a dialog box and having the page time out while they were
    typing.
    Anyone got a trickier (javascript, I'd assume) way to set timeouts so
    that a keystroke, or even a mouse movement resets the timer? Even if it
    only worked with keystrokes and not mouse movement it would be an
    improvement. LMK.

    Thanks!

    Matt
     
    MattB, Aug 30, 2006
    #1
    1. Advertising

  2. This is unedited production code, sort thru it and take what you want.

    //in the form tag
    <BODY onkeypress="window_activity()" onmousedown="window_activity()" ...

    //in your javascript file
    'the next few functions enable the timer which times out the user after
    inactivity period
    Sub StopTiming()
    if timerPROMPT > 0 then
    window.clearTimeout timerPROMPT
    end if

    sTime = Now
    if msgbox ("Due to inactivity, your session is about to time out. Press OK
    to remain connected, Cancel to end your session.",vbOkCancel,"Logout in
    Progress") = 1 then
    eTime = Now
    elapsed = DateDiff("m",sTime,eTime)

    'user had 2 minutes to respond
    if elapsed > 2 then
    document.all.SPREADSHEET_COMMAND.value = "CLOSE"
    ClearRates()
    else
    window_activity()
    end if
    else
    ClearRates()
    document.all.SPREADSHEET_COMMAND.value = "CLOSE"
    end if
    End Sub
    'monitor for user activity to determine when to time out the user
    Sub window_activity()
    if timerPROMPT > 0 then
    window.clearTimeout(timerPROMPT)
    end if

    timerPROMPT = window.setTimeout("StopTiming()",1800000)
    End Sub


    --
    ________________________
    Warm regards,
    Alvin Bruney [MVP ASP.NET]

    [Shameless Author plug]
    Professional VSTO.NET - Wrox/Wiley
    The O.W.C. Black Book with .NET
    www.lulu.com/owc, Amazon
    Blog: http://www.msmvps.com/blogs/alvin
    -------------------------------------------------------


    "MattB" <> wrote in message
    news:...
    > I'm using the old html method of creating timeouts for my asp.net (1.1)
    > pages. This apparently isn't working as well as I'd hoped because it takes
    > a postback to reset the timer. I've had complaints of people typing into a
    > dialog box and having the page time out while they were typing.
    > Anyone got a trickier (javascript, I'd assume) way to set timeouts so that
    > a keystroke, or even a mouse movement resets the timer? Even if it only
    > worked with keystrokes and not mouse movement it would be an improvement.
    > LMK.
    >
    > Thanks!
    >
    > Matt
     
    Alvin Bruney [MVP], Aug 31, 2006
    #2
    1. Advertising

  3. MattB

    MattB Guest

    Alvin Bruney [MVP] wrote:
    > This is unedited production code, sort thru it and take what you want.
    >
    > //in the form tag
    > <BODY onkeypress="window_activity()" onmousedown="window_activity()" ...
    >
    > //in your javascript file
    > 'the next few functions enable the timer which times out the user after
    > inactivity period
    > Sub StopTiming()
    > if timerPROMPT > 0 then
    > window.clearTimeout timerPROMPT
    > end if
    >
    > sTime = Now
    > if msgbox ("Due to inactivity, your session is about to time out. Press OK
    > to remain connected, Cancel to end your session.",vbOkCancel,"Logout in
    > Progress") = 1 then
    > eTime = Now
    > elapsed = DateDiff("m",sTime,eTime)
    >
    > 'user had 2 minutes to respond
    > if elapsed > 2 then
    > document.all.SPREADSHEET_COMMAND.value = "CLOSE"
    > ClearRates()
    > else
    > window_activity()
    > end if
    > else
    > ClearRates()
    > document.all.SPREADSHEET_COMMAND.value = "CLOSE"
    > end if
    > End Sub
    > 'monitor for user activity to determine when to time out the user
    > Sub window_activity()
    > if timerPROMPT > 0 then
    > window.clearTimeout(timerPROMPT)
    > end if
    >
    > timerPROMPT = window.setTimeout("StopTiming()",1800000)
    > End Sub
    >
    >


    Great Thanks!

    Matt
     
    MattB, Aug 31, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Bencsik
    Replies:
    2
    Views:
    856
  2. vh
    Replies:
    2
    Views:
    890
  3. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,306
    Brian Candler
    Oct 6, 2004
  4. Andrew Thompson
    Replies:
    8
    Views:
    158
    Premshree Pillai
    Jun 7, 2005
  5. Replies:
    2
    Views:
    61
    Mark H Harris
    May 13, 2014
Loading...

Share This Page