Asp.net Session how To pass Session One Page to another page
Introduction :
This Artical Explain How to Pass user name and Login time From Login page To Home Page in asp.net
Step 1: Open Visual Studio and Create New Web Project
Step 2 : Add webform And give name Login.aspx and pass user name& login Time as following
namespace Web_Session
{
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["name"] = TextBox1.Text;
string abc = DateTime.Now.ToLongTimeString();
Session["login_time"] = abc;
Response.Redirect("home.aspx");
}
}
{
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["name"] = TextBox1.Text;
string abc = DateTime.Now.ToLongTimeString();
Session["login_time"] = abc;
Response.Redirect("home.aspx");
}
}
Step 3 : Now Create Anothe Webform and give name home.aspx and add below code in page load
namespace Web_Session
{
public partial class home : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string str = Session["name"].ToString();
Label1.Text = "Wel Come:" + str;
Label2.Text = Session["login_time"].ToString();
}
}
}
{
public partial class home : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string str = Session["name"].ToString();
Label1.Text = "Wel Come:" + str;
Label2.Text = Session["login_time"].ToString();
}
}
}
See Other Tutorial :
* AngularJS With ASP.NET MVC
* Convert Rows to columns using 'Pivot' in SQL Server
* Mvc Registration page With user exist using Ajax method
* MVC 4 How to Perform Insert Update Delete Edit Select Operation
* MVC4 Edit,update,Delete,cancel inside gridview using sql database
* MVC 4 Gridview To Display Data Using SQL Server Database With Simple code
* Login page in asp.net Mvc4 Web application
* Mvc4 How to bind Dropdown List using Sql Database
* Gridview find control in asp.net
* AngularJS With ASP.NET MVC
* Convert Rows to columns using 'Pivot' in SQL Server
* Mvc Registration page With user exist using Ajax method
* MVC 4 How to Perform Insert Update Delete Edit Select Operation
* MVC4 Edit,update,Delete,cancel inside gridview using sql database
* MVC 4 Gridview To Display Data Using SQL Server Database With Simple code
* Login page in asp.net Mvc4 Web application
* Mvc4 How to bind Dropdown List using Sql Database
* Gridview find control in asp.net
Sign up here with your email
ConversionConversion EmoticonEmoticon