Variables retaining values

D

Damien Kay

Hi,

I am relatively new to ASP.NET programming and have a problem with a web
form that I have developed:

I have a boolean variable which should be false when the application first
starts but which is set to true when I populate an array. I have an "Close
Window" command button which executes the following code:

Response.Write("<script>window.close();</script>")


If I close the form using the command button and then re-launch the
application everything works fine i.e. the variable is set back to false.
However, if I close the form by clicking the "X" in the top right corner and
re-launch the application the variable has retained it's true value from the
previous time the application was run.

Does anyone know why this is and how I can get around it?

Thanks in advance,
Damien.
 
A

avnrao

you can set that variable in the client side script.
onbodyunload - call a method to set it.

Av.
 
D

Damien Kay

Thanks Av,

Sorry for my lack of knowledge on this, but how do I do that ?

Damien
 
A

avnrao

your page body tag.
<script language='javascript'>
function setVariableToFalse()
{
yourForm.yourVariable = false;
}
</script>
<body onbeforeunload="setVariableToFalse();">

if you need any help, you can post your code here for me to understand it
better.
hth,
Av.
 
D

Damien Kay

Thanks Av, I will give that a go!

avnrao said:
your page body tag.
<script language='javascript'>
function setVariableToFalse()
{
yourForm.yourVariable = false;
}
</script>
<body onbeforeunload="setVariableToFalse();">

if you need any help, you can post your code here for me to understand it
better.
hth,
Av.
 
D

Damien Kay

Hi Av,

It still doesn't work but I am sure it is my code, here it is:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ETCKMA.aspx.vb"
Inherits="ETCKMA.ETCKMA" EnableSessionState="True"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Keyword Maintenance</title>
<meta content="True" name="vs_showGrid">
<LINK href="CRMTemplate.css" type="text/css" rel="stylesheet">
<LINK href="CRMDialogs.css" type="text/css" rel="stylesheet">
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="VBScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<script language='javascript'>
function setVariableToFalse()
{
Form1.blnKeywordArrayPopulated = false;
}
</script>
<body MS_POSITIONING="GridLayout" onbeforeunload="setVariableToFalse();">
<form id="Form1" method="post" runat="server">
<asp:label id="Label3" ... lots of controls listed
here...></asp:imagebutton></form>
</body>
</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top