JAVASCRIPT :
var sessionTimeout = <%= Session.Timeout %>
function DisplaySessionTimeout() {
sessionTimeout = sessionTimeout - 1;
window.setTimeout("DisplaySessionTimeout()", 60000);
if (sessionTimeout == 0) {
window.location = "../Login.aspx";
}
}
Here the above mentioned script need to be called in the PageLoad of the page which works like a timer. This may be on serverside (or) clientside.
Server side pageload as follows :
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "onLoad", "DisplaySessionTimeout();",true);
}
Client side page load as follows :
function pageLoad()
{
DisplaySessionTimeout();
}
Description :
<%= Session.Timeout %> will get the time which we have given on "web.config".
Forevery minute it will check the session time and get logged out when session get expired.
Implement this script on "MasterPage" will be useful for entire application which are linked to it.
var sessionTimeout = <%= Session.Timeout %>
function DisplaySessionTimeout() {
sessionTimeout = sessionTimeout - 1;
window.setTimeout("DisplaySessionTimeout()", 60000);
if (sessionTimeout == 0) {
window.location = "../Login.aspx";
}
}
Here the above mentioned script need to be called in the PageLoad of the page which works like a timer. This may be on serverside (or) clientside.
Server side pageload as follows :
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "onLoad", "DisplaySessionTimeout();",true);
}
Client side page load as follows :
function pageLoad()
{
DisplaySessionTimeout();
}
Description :
<%= Session.Timeout %> will get the time which we have given on "web.config".
Forevery minute it will check the session time and get logged out when session get expired.
Implement this script on "MasterPage" will be useful for entire application which are linked to it.
Hai sir i want the code for photo upload.
ReplyDeleteWhich Type Of upload i.e., single file upload or multi file upload ... can u send me Your exact requirement??
DeleteWow... This was very helpful... Thank you very much..
ReplyDelete"For every minute it will check the session time"
ReplyDeleteHow will that work if you are using setTimeout function?
I need explanation for this.