I am trying to create an aspx page that shows multiple forms to the user. To do that, I have a pagenumber variable that I increment. Then I use If Then lines to display the appropriate user input pages.
The problem that I am running into is that each time a user clicks on the Next button to show the next page, I lose values from variables that stored previous page inputs. Below is an example of my coding scheme. By the time it loads the PageNumber=3 info, the UserName variable has lost its value. How do I keep the values applied to the variables?
<%@ Page Language="
VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.IO" %>
<Script runat="server">
Public PageNumber as Integer=1
Public UserName, Phone as String
Sub Page1Next(Sender As Object, e As EventArgs)
UserName=txtName.Text
PageNumber=2
End Sub
Sub Page2Next(Sender As Object, e As EventArgs)
Phone=txtPhone.Text
PageNumber=3
End Sub
</Script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Test</title>
</head>
<body>
<form method="POST" runat="server">
<% if PageNumber=1 then %>
Enter Name <asp:TextBox ID="txtName" Runat="server" />
<asp:Button id="btnNext1" Text="Next" Runat="server" OnClick="Page1Next" />
<% end if %>
<% if PageNumber=2 then %>
Enter Phone Number <asp:TextBox ID="txtPhone" Runat="server" />
<asp:Button id="btnNext2" Text="Next" Runat="server" OnClick="Page2Next" />
<% end if %>
<% if PageNumber=3 then %>
Enter City <asp:TextBox ID="txtCity" Runat="server" />
<% end if %>
</form>
</body>
</html>