Doing some javascript for the first time. I'm playing around with a sessiontimeout and it was working well while I had the code within the .aspx page. Next stape was to put the code in a .js page. So here's my current lineup.
Script.aspx.js
var iddleTimeoutWarning = null;
var iddleTimeout = null;
function pageLoad()
{
if (iddleTimeoutWarning != null)
clearTimeout(iddleTimeoutWarning);
if (iddleTimeout != null)
clearTimeout(iddleTimeout);
var millisecTimeOutWarning = <%= int.Parse(System.Configuration.ConfigurationManager.AppSettings["SessionTimeoutWarning"]) * 60 * 1000 %>;
var millisecTimeOut = <%= int.Parse(System.Configuration.ConfigurationManager.AppSettings["SessionTimeout"]) * 60 * 1000 %>;
iddleTimeoutWarning = setTimeout("DisplayIddleWarning()", millisecTimeOutWarning);
iddleTimeout = setTimeout("TimeoutPage()", millisecTimeOut);
}
function DisplayIddleWarning()
{
document.getElementById("LblWarning").innerHTML = "Warning Message";
}
function TimeoutPage()
{
__doPostBack('FiresAutoIdle','');
}
ASPX page (Pretty sure error is here since the code in .js page works)
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="Scripts/Script.aspx.js"/>
</Scripts>
</asp:ScriptManager>
I also have some code lines in web.config to set keys SessionTimeout and SessionTimeoutWarning.
So, any idea on where's the glitch? Things used to run, now they won't.
EDIT
- I'm using a script manager for a quick handling of the necessary ASP.NET AJAX components to enable partial postback. I need __doPostBack.
- I found out if a js function is named pageLoad(), the function will activate when the page loads or when a partial postback. Just what I need.
So, asp.nex page is not loading pageLoad() function from .js.