I want to alert the user that the session timeout is about to expire. I want to have a popup with an OK button and show the seconds ticking down on the popup. Can i do this with just java script?
Im OK with using C# code behind also.
Right now it detects session timeout and pops up telling them the session has expired.
<script type="text/javascript">
var sessionTimeout = "<%= Session.Timeout %>";
function DisplaySessionTimeout() {
sessionTimeout = sessionTimeout - 1;
if (sessionTimeout >= 0)
window.setTimeout("DisplaySessionTimeout()", 60000);
else {
alert("Your current Session is over due to inactivity.");
}
}
</script>
Yes, you can do this via JavaScript. Here’s a simple counter implementation that was inspired from this StackOverflow answer I found a while back:
… and an example of how to use it:
Once the server is ready to alert the user, just create the timer and it’ll start counting down. You can customize what happens on each event: when timer starts, when a second ticks by, and when the countdown is done.