By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,374 Members | 1,768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,374 IT Pros & Developers. It's quick & easy.

Variables retaining values

P: n/a
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.
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


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

Av.
"Damien Kay" <sp**@no-spam.com> wrote in message
news:O0**************@TK2MSFTNGP12.phx.gbl...
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.

Nov 18 '05 #2

P: n/a
Thanks Av,

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

Damien

"avnrao" <av*@newsgroups.com> wrote in message
news:Of*************@TK2MSFTNGP11.phx.gbl...
you can set that variable in the client side script.
onbodyunload - call a method to set it.

Av.
"Damien Kay" <sp**@no-spam.com> wrote in message
news:O0**************@TK2MSFTNGP12.phx.gbl...
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.


Nov 18 '05 #3

P: n/a
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.
"Damien Kay" <sp**@no-spam.com> wrote in message
news:uL**************@TK2MSFTNGP10.phx.gbl...
Thanks Av,

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

Damien

"avnrao" <av*@newsgroups.com> wrote in message
news:Of*************@TK2MSFTNGP11.phx.gbl...
you can set that variable in the client side script.
onbodyunload - call a method to set it.

Av.
"Damien Kay" <sp**@no-spam.com> wrote in message
news:O0**************@TK2MSFTNGP12.phx.gbl...
> 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.
>
>



Nov 18 '05 #4

P: n/a
Thanks Av, I will give that a go!

"avnrao" <av*@newsgroups.com> wrote in message
news:er**************@tk2msftngp13.phx.gbl...
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.
"Damien Kay" <sp**@no-spam.com> wrote in message
news:uL**************@TK2MSFTNGP10.phx.gbl...
Thanks Av,

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

Damien

"avnrao" <av*@newsgroups.com> wrote in message
news:Of*************@TK2MSFTNGP11.phx.gbl...
you can set that variable in the client side script.
onbodyunload - call a method to set it.

Av.
"Damien Kay" <sp**@no-spam.com> wrote in message
news:O0**************@TK2MSFTNGP12.phx.gbl...
> 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.
>
>



Nov 18 '05 #5

P: n/a
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>

"avnrao" <av*@newsgroups.com> wrote in message
news:er**************@tk2msftngp13.phx.gbl...
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.
"Damien Kay" <sp**@no-spam.com> wrote in message
news:uL**************@TK2MSFTNGP10.phx.gbl...
Thanks Av,

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

Damien

"avnrao" <av*@newsgroups.com> wrote in message
news:Of*************@TK2MSFTNGP11.phx.gbl...
you can set that variable in the client side script.
onbodyunload - call a method to set it.

Av.
"Damien Kay" <sp**@no-spam.com> wrote in message
news:O0**************@TK2MSFTNGP12.phx.gbl...
> 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.
>
>



Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.