SESSION
The session state is used to maintain the session of each user throughout the application.
Session allows information to be stored in one page and access in another page and support any type of object.
Html Coding for Sending Page
C# Coding for Sending Page
C# Coding for HomePage
The session state is used to maintain the session of each user throughout the application.
Session allows information to be stored in one page and access in another page and support any type of object.
Html Coding for Sending Page
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr><td>
<asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
</td><td>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td></tr>
<tr><td>
<asp:Label ID="Label2" runat="server" Text="Age"></asp:Label>
</td><td>
<asp:TextBox ID="txtAge" runat="server"></asp:TextBox>
</td></tr>
<tr><td>
<asp:Label ID="Label3" runat="server" Text="Mobile"></asp:Label>
</td><td>
<asp:TextBox ID="txtMobile" runat="server"></asp:TextBox>
</td></tr>
<tr><td colspan="2">
<asp:Button ID="Button1" runat="server" Text="Send" OnClick="Button1_Click" />
</td></tr>
</table>
</div>
</form>
</body>
</html>
Html Coding for Home Page
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr><td colspan="2"> WELCOME TO HOMEPAGE</td></tr>
<tr><td> <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label></td>
<td><asp:Label ID="lblName" runat="server" Text="Label"></asp:Label></td></tr>
<tr><td> <asp:Label ID="Label2" runat="server" Text="Age"></asp:Label>
</td><td> <asp:Label ID="lblAge" runat="server" Text="Label"></asp:Label></td></tr>
<tr><td><asp:Label ID="Label3" runat="server" Text="Mobile"></asp:Label></td>
<td> <asp:Label ID="lblMobile" runat="server" Text="Label"></asp:Label></td></tr>
</table>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Sessio : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
txtName.Text = "DotNet";
txtAge.Text = "29";
txtMobile.Text = "0123456789";
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["Name"] = txtName.Text;
Session["Age"] = txtAge.Text;
Session["Mobile"] = txtMobile.Text;
Response.Redirect("homepage.aspx");
}
}
C# Coding for HomePage
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class homepage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblAge.Text = Session["Age"].ToString();
lblName.Text = Session["Name"].ToString();
lblMobile.Text = Session["Mobile"].ToString();
}
}
0 comments:
Post a Comment