I have the following pages:

UserForm.aspx:

<!-- UserForm.aspx -->
<%@ Page Language="VB" ClassName="SenderClass" %>

<script runat="server">
	' Readonly property for name
	Public ReadOnly Property Name() As String
		Get
			Return USerName.Text
		End Get
	End Property

	'Readonly Property for phone
	Public ReadOnly Property Phone() As String
		Get
			Return UserPhone.Text
		End Get
    End Property
    
    ' Readonly property for comments
    Public ReadOnly Property Comment() As String
        Get
            Return Comments.Text
        End Get
    End Property
    
    ' Readonly property for gender
    Public ReadOnly Property GenderRadio() As String
        Get
            Return Gender.Text
        End Get
    End Property
    
    ' Readonly property for pets
    Public ReadOnly Property PetsOwned() As String
        Get
            Return Pets.Text
        End Get
    End Property

	'Event to transfer page control to Result.aspx
	Sub Page_Transfer(sender As Object, e As EventArgs)
		Server.Transfer("Result.aspx")
    End Sub
    
    
   Sub Page_load(ByVal obj As Object, ByVal e As EventArgs)
        
        If Not IsPostBack Then
            UserName.Text = Session("Name")
            UserPhone.Text = Session("Phone")
            Comments.Text = Session("Comment")
            Gender.Text = Session("GenderRadio")
            Pets.Text = Session("PetsOwned")
        End If
        
    End Sub

</script>

<html>
<head>
</head>
<body>
	<form id="Form1" runat="server">
		<table>
		<tr>
		<td>Name: </td>
		<td><asp:TextBox ID="UserName" runat="server" /></td>
		</tr>
		<tr>
		<td>E-mail: </td>
		<td><asp:TextBox ID="UserPhone" runat="server" /></td>
		</tr>
		<tr>
		<td>Gender:</td>
		<td>
            <asp:RadioButtonList ID="Gender" runat="server" 
                RepeatDirection="Horizontal">
                <asp:ListItem>Male</asp:ListItem>
                <asp:ListItem>Female</asp:ListItem>
            </asp:RadioButtonList>
        </td>
		</tr>
		<tr>
		<td>Comments:</td>
		<td>
            <asp:TextBox ID="Comments" runat="server" TextMode="MultiLine"></asp:TextBox></td>
		</tr>
		<tr>
		<td>Pets Owned:</td>
		<td>
            <asp:CheckBoxList ID="Pets" runat="server" RepeatDirection="Horizontal">
                <asp:ListItem>Dog</asp:ListItem>
                <asp:ListItem Value="Cat"></asp:ListItem>
                <asp:ListItem>Bird</asp:ListItem>
                <asp:ListItem>Fish</asp:ListItem>
                <asp:ListItem>Reptile</asp:ListItem>
            </asp:CheckBoxList>
        </td>
		</table><br />
		<asp:Button ID="Button1" Text="Submit" OnClick="Page_Transfer"
			runat="server" />
	</form>
</body>
</html>

Result.aspx:

<!-- Result.aspx -->
<%@ Page Language="VB" %>
<%@ Reference Page="UserForm.aspx" %>

<script runat="server">
    Dim result As SenderClass

	Sub Page_load(obj as Object, e as EventArgs)
		Dim content As String

		If Not IsPostBack Then
			result = CType(Context.Handler, SenderClass)
            content = "Name: " + result.Name + "<br>" + "Phone: " + result.Phone + "<br>" + "Gender: " + result.GenderRadio + "<br>" + "Comments: " + result.Comment + "<br>" + "Pets Owned: " + result.PetsOwned
            Label1.Text = content
            
            Session("Name") = result.Name
            Session("Phone") = result.Phone
            Session("Comment") = result.Comment
            Session("GenderRadio") = result.GenderRadio
            Session("PetsOwned") = result.PetsOwned
            
            
       End If
    End Sub
    Sub Cancel_Click(ByVal sender As Object, ByVal e As EventArgs)
        Server.Transfer("UserForm.aspx")
    End Sub

</script>
<html>
<head>
</head>
<body>
<h1>Summary:</h1>
	<i><form id="Form1" runat="server">
		<asp:Label id="Label1" runat="server" /></i><br /><br />
    <asp:Button ID="Confirm" runat="server" Text="Confirm" 
            PostBackUrl="Guestbook.aspx" />
		&nbsp;
    <asp:Button ID="Cancel" runat="server" Text="Cancel" PostBackUrl="UserForm.aspx" /></form>
</body>
</html>

UserForm sends the form data to the Result page, which displays the data for the user in a summary. How can I pass the value of the checkboxes selected to the next page?

Recommended Answers

All 2 Replies

Seeing you are using session sate you can cycle through the Pets list and save every checked option into an array and store that in the session state for retrivel on the results page. I'm assuming you need the summary on the results page to return a possible pets list of more than one value?

Yes, I do. Can you help me with the array and session? I am still very new to this and I have gotten some of it one, but this the part I'm having trouble with. Someone also helped me with the session part. Can you please show me how to do this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.