S
SilentCry
as a follow up to my original question from a couple weeks back, i did
figure this out. turned out to be pretty easy once i figured out i needed to
use the xmlhttp request object.
in the Page_Load code behind of main page..
Session.Add("SID", Session.SessionID);
int to = Session.Timeout;
// inserts client script below
Page.ClientScript.RegisterStartupScript(typeof(string), "Timeout",
script);
<script> function WarnUser()
{
alert("Your session will expire in 2 minute(s).\nClick OK to
continue your session.");
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST", "SessionEnd.aspx", true);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4)
{
// alert(xmlhttp.responseText);
if(xmlhttp.responseText == "")
{
window.location = "Error.aspx";
}
}
}
xmlhttp.send();
}
window.setInterval('WarnUser()', 1 * 60000);
</script>
code in SessionEnd.aspx (script only)..
<%@ Page Language="c#" AutoEventWireup="false" AspCompat="true" %>
<%
Response.ContentType = "text/plain";
Response.Write(Session["SID"] as string);
%>
doing it this way, i only redirect to a new page in the event the session
has timed out (Session["SID"] == null). otherwise i do nothing allowing the
page i was on to just redisplay through normal focus change keeping the data
filled in in place which is exactly what i wanted.
figure this out. turned out to be pretty easy once i figured out i needed to
use the xmlhttp request object.
in the Page_Load code behind of main page..
Session.Add("SID", Session.SessionID);
int to = Session.Timeout;
// inserts client script below
Page.ClientScript.RegisterStartupScript(typeof(string), "Timeout",
script);
<script> function WarnUser()
{
alert("Your session will expire in 2 minute(s).\nClick OK to
continue your session.");
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST", "SessionEnd.aspx", true);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4)
{
// alert(xmlhttp.responseText);
if(xmlhttp.responseText == "")
{
window.location = "Error.aspx";
}
}
}
xmlhttp.send();
}
window.setInterval('WarnUser()', 1 * 60000);
</script>
code in SessionEnd.aspx (script only)..
<%@ Page Language="c#" AutoEventWireup="false" AspCompat="true" %>
<%
Response.ContentType = "text/plain";
Response.Write(Session["SID"] as string);
%>
doing it this way, i only redirect to a new page in the event the session
has timed out (Session["SID"] == null). otherwise i do nothing allowing the
page i was on to just redisplay through normal focus change keeping the data
filled in in place which is exactly what i wanted.