Using this code i want to show an modal pop up to the user that "your session will be expired within 5 minutes , Click here [BUTTON] to reset your session" , here's my code :
<asp:Button ID="btnReset" Text="Reset" runat="server" OnClick="ResetSession" />
<br />
Your Session will expire in <span id = "seconds"></span> seconds.
<script type="text/javascript">
function SessionExpireAlert(timeout) {
var seconds = timeout / 1000;
seconds--;
document.getElementById("seconds").innerHTML = seconds;
setInterval(function () {
seconds--;
document.getElementById("seconds").innerHTML = seconds;
}, 1000);
setTimeout(function () {
alert("Your session has expired. You will now be redirected.");
window.location = "About.aspx";
}, timeout);
}
</script>
protected void Page_Load(object sender, EventArgs e)
{
Session["Name"] = "Mudassar";
SessionStateSection section = (SessionStateSection) WebConfigurationManager.GetSection("system.web/sessionState");
int timeout = (int)section.Timeout.TotalMinutes * 1000 * 60;
ClientScript.RegisterStartupScript(this.GetType(), "SessionAlert", "SessionExpireAlert(" + timeout + ");", true);
}
protected void ResetSession(object sender, EventArgs e)
{
string name = Session["Name"].ToString();
}
<sessionState timeout="60" />