help on script to read session variable -
12-13-2005
, 12:29 PM
Hi, All,
I write a JavaScript to read session("CheckedFlag") and to decide if i need
to give the message when user close the browser. but it don't work when read
the session variable. I'm using VB.net to write the web application. If
JavaScript won't work, will Jscript work? or is there a way to do that? I'm
new to ASP and ASP.net and here is the code snippet. it looks simple and
there should be a way to do it, but i don't find the one.
thanks for your help
<HEAD>
<script language="JavaScript" runat ="server">
var needToConfirm = true;
window.onbeforeunload = confirmExit;
var SesType ='<%= Session("CheckedFlag")%>';
function confirmExit()
{
if (SesType =="1" || SesType == '1')
{
needToConfirm = false;
}
if (needToConfirm)
return "Are you sure you want to close the browser?";
}
</script>
</HEAD>
<body onbeforeunload ="javascript:confirmExit()">
Test Form
</body> |