S
SilentCry
i know there are a zillion ways to do this and the way i'm doing it
essentially works but it has a minor problem which i'll get to later.
here's the simplified version of what i'm doing..
i have a main page (default.aspx) that has various input fields on it (text,
dropdowns, etc). in the Page_Load for this page i have this..
Session.Add("SID", Session.SessionID);
int to = Session.Timeout;
string curPath =
Page.Request.AppRelativeCurrentExecutionFilePath.Replace("~/", "");
string script = @"<script> function WarnUser()
{
alert('Your session will expire in 2 minute(s).\nClick OK to
continue your session.');
document.location = ""SessionEnd2.aspx?curPath=" + curPath + @""";
}
setTimeout('WarnUser()', " + (to - 2).ToString() + " * 60 * 1000);"
+
"</script>";
Page.ClientScript.RegisterStartupScript(typeof(string), "Timeout",
script);
basically i want to give the user a warning that the session will expire in
2 minutes.
in the Page_Load for SessionEnd2.aspx i have..
string sid = Session["SID"] as string;
string url = Request.QueryString["curPath"];
if (sid == null)
{
Response.Redirect("Error.aspx", true);
}
else
Response.Redirect(url, true);
this all works except that if the session is still active at the time the
user clicks Ok on the alert (the 2 minutes has not expired), the redirect
back to default.aspx (curPath/url) works well enough but in the process,
reloads the page which is not what i want. obviously any input entered in
the controls before the alert appears is now wiped out. this is where i get
stuck. is there a way to do this without reloading default.aspx. basically
what i want is for focus to be given back onto default through the normal
process of window switching as opposed to reload/postback.
any suggestions?
and yes i do have viewstate=true set for all the controls.
essentially works but it has a minor problem which i'll get to later.
here's the simplified version of what i'm doing..
i have a main page (default.aspx) that has various input fields on it (text,
dropdowns, etc). in the Page_Load for this page i have this..
Session.Add("SID", Session.SessionID);
int to = Session.Timeout;
string curPath =
Page.Request.AppRelativeCurrentExecutionFilePath.Replace("~/", "");
string script = @"<script> function WarnUser()
{
alert('Your session will expire in 2 minute(s).\nClick OK to
continue your session.');
document.location = ""SessionEnd2.aspx?curPath=" + curPath + @""";
}
setTimeout('WarnUser()', " + (to - 2).ToString() + " * 60 * 1000);"
+
"</script>";
Page.ClientScript.RegisterStartupScript(typeof(string), "Timeout",
script);
basically i want to give the user a warning that the session will expire in
2 minutes.
in the Page_Load for SessionEnd2.aspx i have..
string sid = Session["SID"] as string;
string url = Request.QueryString["curPath"];
if (sid == null)
{
Response.Redirect("Error.aspx", true);
}
else
Response.Redirect(url, true);
this all works except that if the session is still active at the time the
user clicks Ok on the alert (the 2 minutes has not expired), the redirect
back to default.aspx (curPath/url) works well enough but in the process,
reloads the page which is not what i want. obviously any input entered in
the controls before the alert appears is now wiped out. this is where i get
stuck. is there a way to do this without reloading default.aspx. basically
what i want is for focus to be given back onto default through the normal
process of window switching as opposed to reload/postback.
any suggestions?
and yes i do have viewstate=true set for all the controls.