Link to home
Start Free TrialLog in
Avatar of mmedi005
mmedi005

asked on

If I use Session_End in Global.asax, how can I give a warning, but if the user clicks ok in a message box, the Session is restored?

If I use Session_End in Global.asax, how can I give a warning in a messaeg box?

If the user clicks ok in a message box, the Session is restored and Session time is restarted?

Is this possible?
Avatar of Rejojohny
Rejojohny
Flag of United States of America image

this is possible, but not the way you think .. i.e not in session_end .. you will have to use javascript to give the warning some minutes before the actual timeout set for the session .. something like this .. note this code will need to be in all your pages and it would be better you have in a .js file and include that in all the aspx pages

<script>
var sessiontimeout = 20; \\default timeout for web application .. change this if you have changed the default
sessiontimeout = (sessionTimeout-1)*60*1000;
setTimeout('sessionWarning()', sTimeout);

function sessionWarning()
{
   alert('session will timeout in 1 minute');
}
</script>

Avatar of mmedi005
mmedi005

ASKER

Lets say the user has been warned, if they click ok, does that restart the Session?

If No, what would I have to do so that the Session Timeout is restarted?
>>If No, what would I have to do so that the Session Timeout is restarted?
you will need to refresh the page for the session to be updated on the server ... you can refresh by redirecting to the same page .. again using javascript like
document.location.href = 'samepage.aspx'

Rejo
will information inside the text boxes be cleared on the forms refresh?
ASKER CERTIFIED SOLUTION
Avatar of Rejojohny
Rejojohny
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial