ASP 101 - Active Server Pages 101 form_viewstate.aspx
<%@ Page Language="VB" %>
<script runat="server">
	Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
		If Page.IsValid Then
			' Do whatever processing you want to do when the form is completed here.
			If chkAgree.Checked Then
				' Agreed To Terms
				'Response.Write("<pre>")
				'Response.Write("Name: " & txtName.Text & vbCrLf)
				'Response.Write("Gender: " & rblGender.SelectedValue & vbCrLf)
				'Response.Write("Favorite Color: " & ddlColor.SelectedValue & vbCrLf)
				'Response.Write("Agree To Terms: " & chkAgree.Checked & vbCrLf)
				'Response.Write("</pre>")
			Else
				' Did Not Agree To Terms
			End If
		Else
			' Validation error.
		End If
	End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>ASP.NET Form ViewState Sample</title>
</head>
<body>
<form id="myForm" runat="server">
<div>
<table border="0">
	<tr>
		<td align="right"><asp:Label ID="lblName" runat="server" Text="Name:" AssociatedControlID="txtName" /></td>
		<td>
			<asp:TextBox ID="txtName" runat="server" />
			<asp:RequiredFieldValidator runat="server"
				ID="valNameRequired"
				ControlToValidate="txtName"
			/>
		</td>
	</tr>
	<tr>
		<td align="right"><asp:Label ID="lblGender" runat="server" Text="Gender:" AssociatedControlID="rblGender" /></td>
		<td>
			<asp:RadioButtonList ID="rblGender" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
				<asp:ListItem>Male</asp:ListItem>
				<asp:ListItem>Female</asp:ListItem>
			</asp:RadioButtonList>
			<asp:RequiredFieldValidator runat="server"
				ID="valGenderRequired"
				ControlToValidate="rblGender"
			/>
		</td>
	</tr>
	<tr>
		<td align="right"><asp:Label ID="lblColor" runat="server" Text="Favorite Color:" AssociatedControlID="ddlColor" /></td>
		<td>
			<asp:DropDownList ID="ddlColor" runat="server">
				<asp:ListItem>Red</asp:ListItem>
				<asp:ListItem>Orange</asp:ListItem>
				<asp:ListItem>Yellow</asp:ListItem>
				<asp:ListItem>Green</asp:ListItem>
				<asp:ListItem>Blue</asp:ListItem>
				<asp:ListItem>Indigo</asp:ListItem>
				<asp:ListItem>Violet</asp:ListItem>
			</asp:DropDownList>
			<asp:RequiredFieldValidator runat="server"
				ID="valColorRequired"
				ControlToValidate="ddlColor"
			/>
		</td>
	</tr>
	<tr>
		<td align="right"><asp:Label ID="lblAgree" runat="server" Text="Agree To Terms:" AssociatedControlID="chkAgree" /></td>
		<td>
			<asp:CheckBox ID="chkAgree" runat="server" />
		</td>
	</tr>
	<tr>
		<td></td>
		<td><asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click" Text="Submit" /></td>
	</tr>
</table>
<p>
<strong>Note:</strong> 
The point of this sample is to illustrate repopulating the form fields with
the values the user enters.  As such, regardless of the values entered,
the form will not actually do anything when submitted.  This is intentional.
To change this behavior, please read the comments included in the source code.
</p>
</div>
</form>
<hr />
<p>
Click <a href="http://www.asp101.com/samples/form_viewstate_aspx.asp">here</a>
to read about and download the source code.
</p>
</body>
</html>