473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

panels and variable state

Hi all,

I was just playing around with some code to hide/show panels and I
discovered that I am losing a variable's value when my sub is called from a
button in paneltwo. Why is this?

Cheers and Thanks, Lerp

Code below:
<script language="vb" runat="server">

Dim myvalue as Long

SUB Page_Load(Sender As Object, E As EventArgs)
panelone.visible = true
paneltwo.visible = false
END SUB

Sub One(Sender As Object, E As EventArgs)
myvalue = 7
panelone.visible = false
paneltwo.visible = true
response.write(myvalue & " IS MY VALUE" & "<BR>")
End Sub
Sub Two(Sender As Object, E As EventArgs)
Dim curVal = myvalue
panelone.visible = true
paneltwo.visible = false
response.write(curVal & " IS CurVal VALUE" & "<BR>")
******************************** This turns out to be ZERO

End Sub

</script>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head></head>
<body>

<form runat="server">

<asp:panel ID="panelone" runat="server">
<table width="600" cellpadding="2" cellspacing="0" border="0">
<tr valign="top">
<td align="left" class="bodycopy">
<asp:Button id="submitform1" text="Panel One Button" OnClick="One"
runat="server" CssClass="but" />
</td>
</tr>
</table>
</asp:panel>
<asp:panel ID="paneltwo" runat="server">
<table width="600" cellpadding="2" cellspacing="0" border="0">
<tr valign="top">
<td align="left" class="bodycopy">
<asp:Button id="submitform2" text="Panel Two Button" OnClick="Two"
runat="server" CssClass="but" />
</td>
</tr>
</table>
</asp:panel>
</form>
</body>
</html>
Nov 18 '05 #1
2 1308
HTTP is stateless. This means that every time a Page Posts back, everything
is re-initialized. If you change the value of a private member of your class
in one instance, you have to persist it somehow between PostBacks.
ViewState, Session, etc.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Lerp" <ad***@officience.ca> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
Hi all,

I was just playing around with some code to hide/show panels and I
discovered that I am losing a variable's value when my sub is called from a button in paneltwo. Why is this?

Cheers and Thanks, Lerp

Code below:
<script language="vb" runat="server">

Dim myvalue as Long

SUB Page_Load(Sender As Object, E As EventArgs)
panelone.visible = true
paneltwo.visible = false
END SUB

Sub One(Sender As Object, E As EventArgs)
myvalue = 7
panelone.visible = false
paneltwo.visible = true
response.write(myvalue & " IS MY VALUE" & "<BR>")
End Sub
Sub Two(Sender As Object, E As EventArgs)
Dim curVal = myvalue
panelone.visible = true
paneltwo.visible = false
response.write(curVal & " IS CurVal VALUE" & "<BR>")
******************************** This turns out to be ZERO

End Sub

</script>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head></head>
<body>

<form runat="server">

<asp:panel ID="panelone" runat="server">
<table width="600" cellpadding="2" cellspacing="0" border="0">
<tr valign="top">
<td align="left" class="bodycopy">
<asp:Button id="submitform1" text="Panel One Button" OnClick="One"
runat="server" CssClass="but" />
</td>
</tr>
</table>
</asp:panel>
<asp:panel ID="paneltwo" runat="server">
<table width="600" cellpadding="2" cellspacing="0" border="0">
<tr valign="top">
<td align="left" class="bodycopy">
<asp:Button id="submitform2" text="Panel Two Button" OnClick="Two"
runat="server" CssClass="but" />
</td>
</tr>
</table>
</asp:panel>
</form>
</body>
</html>

Nov 18 '05 #2
ah man, I knew it....

I ended up using session vars anyways...thx for help.

Thx Kevin,

Cheers, Lerp
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:Ol**************@TK2MSFTNGP11.phx.gbl...
HTTP is stateless. This means that every time a Page Posts back, everything is re-initialized. If you change the value of a private member of your class in one instance, you have to persist it somehow between PostBacks.
ViewState, Session, etc.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Lerp" <ad***@officience.ca> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
Hi all,

I was just playing around with some code to hide/show panels and I
discovered that I am losing a variable's value when my sub is called
from a
button in paneltwo. Why is this?

Cheers and Thanks, Lerp

Code below:
<script language="vb" runat="server">

Dim myvalue as Long

SUB Page_Load(Sender As Object, E As EventArgs)
panelone.visible = true
paneltwo.visible = false
END SUB

Sub One(Sender As Object, E As EventArgs)
myvalue = 7
panelone.visible = false
paneltwo.visible = true
response.write(myvalue & " IS MY VALUE" & "<BR>")
End Sub
Sub Two(Sender As Object, E As EventArgs)
Dim curVal = myvalue
panelone.visible = true
paneltwo.visible = false
response.write(curVal & " IS CurVal VALUE" & "<BR>")
******************************** This turns out to be ZERO

End Sub

</script>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head></head>
<body>

<form runat="server">

<asp:panel ID="panelone" runat="server">
<table width="600" cellpadding="2" cellspacing="0" border="0">
<tr valign="top">
<td align="left" class="bodycopy">
<asp:Button id="submitform1" text="Panel One Button" OnClick="One"
runat="server" CssClass="but" />
</td>
</tr>
</table>
</asp:panel>
<asp:panel ID="paneltwo" runat="server">
<table width="600" cellpadding="2" cellspacing="0" border="0">
<tr valign="top">
<td align="left" class="bodycopy">
<asp:Button id="submitform2" text="Panel Two Button" OnClick="Two"
runat="server" CssClass="but" />
</td>
</tr>
</table>
</asp:panel>
</form>
</body>
</html>


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Phil Powell | last post by:
print_r("From index.php 20: $prefix: stateXML = $stateXML<P>"); foreach (array('state', 'country') as $prefix) { print_r("From index.php 21: stateXML = $stateXML<P>"); ${$prefix . 'XML'} =...
0
by: PZ | last post by:
OSS 2005 The First International Conference on Open Source Systems Genova, July 11 - 15, 2005 CALL FOR PANELS http://oss2005.case.unibz.it Submissions of panels are solicited for the "First...
0
by: PZ | last post by:
OSS 2005 The First International Conference on Open Source Systems Genova, July 11 - 15, 2005 CALL FOR PANELS http://oss2005.case.unibz.it Submissions of panels are solicited for the "First...
1
by: pfnus | last post by:
Hi, I want to display different forms when the buttons are clicked and all the forms are having different controls on it. So instead of adding new windows forms to the project, i enlarged the...
41
by: Miguel Dias Moura | last post by:
Hello, I am working on an ASP.NET / VB page and I created a variable "query": Sub Page_Load(sender As Object, e As System.EventArgs) Dim query as String = String.Empty ... query =...
1
by: Demetri | last post by:
I'm trying to determine if we want to use panels or user controls for our pages. Our primary concern is performance, page loading and posting speed. To illustrate my question, lets use the...
8
by: Søren Dreijer | last post by:
Hi, I realize this is a very common problem, but even though I've scoured the Internet for resources, I can't seem to solve this issue :| I currently have a very simple application. It...
2
by: Kristof Taveirne | last post by:
Hi, I'm developing an application on PDA using WindowsCE. In my application I have several tabs at the bottom of my screen. However, in one of the tabs I've placed 2 radiobutton, used to switch...
1
by: Ben | last post by:
Hi We have a number of Panels on our windows form, we have controls inside and outside of the panels. I am having problems tabbing between controls, it appers to be when the controls are...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.