[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1095
  • Last Modified:

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?
0
mmedi005
Asked:
mmedi005
  • 3
  • 2
1 Solution
 
RejojohnyCommented:
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>

0
 
mmedi005Author Commented:
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?
0
 
RejojohnyCommented:
>>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
0
 
mmedi005Author Commented:
will information inside the text boxes be cleared on the forms refresh?
0
 
RejojohnyCommented:
yes .. it will be like a fresh load .. so if you have code which fills the values in the textbox, then they will be reset to those values.. if you want the page to retain then you will have to submit the page .. try document.forms(0).submit() .. note this will also fire the page load event ..

Rejo
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now