473,383 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Better timeout mechanism?

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
Aug 30 '06 #1
2 1343
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" <so********@yahoo.comwrote in message
news:4l************@individual.net...
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

Aug 30 '06 #2
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
Aug 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Pietje de kort | last post by:
Hello all, I am trying to build a class that does something, and may timeout while doing so. Ofcouse I want to be a bit elegant, so I came up with the code found below. Problem is, I can't catch...
4
by: Joseph | last post by:
I have an intranet application that I setup using windows authentication through IIS basic authentication. Is there a way to set a timeout, so that after ten minutes the user will be prompted...
2
by: francois | last post by:
in my web.config i have the following : <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
5
by: mapexvenus | last post by:
I have a .NET application that uses SQL server. After some useage I get the following error: "Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may...
15
by: dee | last post by:
Hi, What is the maximum number of minutes for Session timeout that I can specify in web.config? Thanks. Dee
4
by: Sosh | last post by:
Hi, I wonder if anyone knows how an application that employs remote scripting/callbacks should deal with an authentication timeout during a callback? At the moment my application just stops...
12
by: Jens Jensen | last post by:
I try to set the timeout property on my HttpWebRequest object before lunching the request. It seems like any value above 100 seconds is discarded. Has anyone observered malfunctional with this...
2
by: dmitry.sychov | last post by:
Hello, 1) On UDF timeout the timeout error is return to the caller, but what happens with the UDF's thread? - does it terminated via Windows TerminateThread() or db2 engine thread waits for...
22
by: Nick Craig-Wood | last post by:
Did anyone write a contextmanager implementing a timeout for python2.5? I'd love to be able to write something like with timeout(5.0) as exceeded: some_long_running_stuff() if exceeded:...
25
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
I tried: <sessionState timeout="1"> </sessionState> bounced IIS, and after 1 minute still had a session. ??? -- thanks - dave
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.