session or query string, or the code below will do it using the Reference
Page attribute
--
Regards
John Timney
ASP.NET MVP
Microsoft Regional Director
Newbie said:
How do I pass string values from one webform to another?
<%@ Page Language="VB" ClassName="FirstPageClass" %>
<html>
<head>
<script runat="server">
Public ReadOnly Property FirstName() As String
Get
' first is the name of a TextBox control.
Return first.Text
End Get
End Property
Public ReadOnly Property LastName() As String
Get
' last is the name of a TextBox control.
Return last.Text
End Get
End Property
Sub ButtonClicked(sender As Object, e As EventArgs)
Server.Transfer("ReceivingValuesPage.aspx")
End Sub
</script>
</head>
<body>
<form runat="server">
First Name:
<asp:TextBox id="first"
runat="server"/>
<br>
Last Name:
<asp:TextBox id="last"
runat="server"/>
<br>
<asp:Button
OnClick="ButtonClicked"
Text="Go to second page"
runat=server />
</form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Reference Page="passingValuesPage.aspx" %>
<html>
<head>
<script runat="server">
Dim fp As FirstPageClass
Sub Page_Load()
If Not IsPostBack Then
fp = CType(Context.Handler, FirstPageClass)
End If
End Sub
</script>
</head>
<body>
<form runat="server">
Hello <%=fp.FirstName%> <%=fp.LastName%>
</form>
</body>
</html>