Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
how to pass the object value from one page to another page using session in asp.net c#
Posted 17-Dec-12 19:39pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

From Login Page:
protected void loginbtn_Click(object sender, EventArgs e)
       {
           string username, password;
 
           username = unametxt.Text;
           password = pswdtxt.Text;
 
           Session["username"] = username;
           Session["password"] = password;
}
 
Another Page after Login:
 
string username = Session ["username"].toString();
string pwd = Session ["password"].toString();
  Permalink  
Comments
Member 8110943 at 18-Dec-12 1:10am
   
string username = Session["uname"].ToString();
string password = Session["pwd"].ToString();
cn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "SP_TRACK_USE";
cmd.Parameters.AddWithValue("@Username",username);
cmd.Parameters.AddWithValue("@Password", password);
cmd.Parameters.AddWithValue("@COMMAND", 1);
cmd.ExecuteScalar();
cn.Close();

sir,this code doesn,t store the logout time in database.so,please remove my pbm.
AshishChaudha at 18-Dec-12 1:31am
   
my vote
Member 8110943 at 18-Dec-12 1:44am
   
hey,any1 give me answer...please
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

http://ramanisandeep.net/2008/11/21/passing-values-from-one-page-to-another-page-aspnet/[^]
http://shawpnendu.blogspot.in/2009/04/passing-dataparametersvalues-from-one.html[^]
 
protected void loginbtn_Click(object sender, EventArgs e)
       {
           string username, password;
 
           username = unametxt.Text;
           password = pswdtxt.Text;
 
           Session["username"] = username;
           Session["password"] = password;
}
  Permalink  
Comments
Member 8110943 at 18-Dec-12 1:00am
   
how to code on logout button to pass the value from login page textbox to logout page and also want to store the logout into database..sir please reply i want full code of this pbm.
Krunal Rohit at 18-Dec-12 1:09am
   
Member 8110943 at 18-Dec-12 1:38am
   
string username = Session["uname"].ToString();
string password = Session["pwd"].ToString();
cn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "SP_TRACK_USE";
cmd.Parameters.AddWithValue("@Username",username);
cmd.Parameters.AddWithValue("@Password", password);
cmd.Parameters.AddWithValue("@COMMAND", 1);
cmd.ExecuteScalar();
cn.Close();
it work properly,but it doesn,t save the log outtime in databse,when i click on logout button..In default.aspx page username,password and a login button and in logout.aspx logout button are present.so please give me solution.
Krunal Rohit at 18-Dec-12 7:40am
   
for that take another session object like Session["LogOutTime"] and write code on LogOutBtn_Click, Session["LogOutTime"] = DateTime.Now;
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

There are many many to pass the value from one page to another.
You can pass value through Querystring or you can use Session for the same.
 
Thanks
  Permalink  
Comments
Tarun Y Mangukiya at 18-Dec-12 1:56am
   
Ya. Right.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 190
1 Jochen Arndt 155
2 PIEBALDconsult 150
3 Afzaal Ahmad Zeeshan 120
4 DamithSL 115
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100