<%@dotnet.itags.org. Page Language="VB" Debug="True" %>
<script language="vb" runat="server">
Dim var As String
Sub button1_click(sender As object, e As EventArgs)
var = "one"
Response.Write(var)
End Sub
Sub button2_click(sender As object, e As EventArgs)
Response.Write(var)
End Sub
</script>
<html>
<head>
<title>Untitled Document</title>
</head
<body>
<form runat="server">
<asp:Button ID="button1" OnClick="button1_click" Text="one" runat="server"></asp:Button>
<asp:Button ID="button2" OnClick="button2_click" Text="two" runat="server"></asp:Button>
</form>
</body>
</html
The problem is when I click button 2 it response.writes nothing. It should spit out "one". Is there anyway I can share variables between multiple subs?When you click button2, the page is reloaded and "var" is redecleared and the button1 value is gone. You may need use ViewState or Session State to keep the value when page reload or redirect to other page.
0 comments:
Post a Comment