Page 1
.aspx Page
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication2.WebForm1" %>
<!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 runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="lblFirstName" runat="server" Text="First Name"></asp:Label>
<asp:TextBox ID="txtFirstName" runat="server" ></asp:TextBox><br />
<asp:Label ID="lblMiddleName" runat="server" Text="Middle Name"></asp:Label>
<asp:TextBox ID="txtMiddleName" runat="server" ></asp:TextBox><br />
<asp:Label ID="lblLastName" runat="server" Text="Last Name"></asp:Label>
<asp:TextBox ID="txtLastName" runat="server" ></asp:TextBox><br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
onclick="btnSubmit_Click" />
</form>
</body>
</html>
.cs Page
using System;
namespace WebApplication2
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
Session["FirstName"] = txtFirstName.Text;
Session["MiddleName"] = txtMiddleName.Text;
Session["LastName"] = txtLastName.Text;
Response.Redirect("WebForm2.aspx");
}
}
}
Page 2
.aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication2.WebForm2" %>
<!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 runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblFirstName" runat="server" Text="First Name"></asp:Label><br />
<asp:Label ID="lblMiddleName" runat="server" Text="Middle Name"></asp:Label><br />
<asp:Label ID="lblLastName" runat="server" Text="Last Name"></asp:Label>
</div>
</form>
</body>
</html>
.cs page
using System;
namespace WebApplication2
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblFirstName.Text = Session["FirstName"].ToString();
lblMiddleName.Text = Session["MiddleName"].ToString();
lblLastName.Text = Session["LastName"].ToString();
}
}
}