L
Lerp
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">
<aspanel 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>
</aspanel>
<aspanel 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>
</aspanel>
</form>
</body>
</html>
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">
<aspanel 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>
</aspanel>
<aspanel 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>
</aspanel>
</form>
</body>
</html>