Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Hi all,
 
I am new to ASP.Net and C#.
I can't understand what is session.
For example, I can create a Session in aspx.cs page like...
session.add("userid", txtusername); 
but I don't know, what is this and how can I get the user id in next page ?
 
Please help me.
Posted 17-Feb-13 5:39am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Dear Session is an object which contain information which you want to carry over
Suppose in your page1.aspx there is a test box whose ID is txt_user and a button
And if you want to use this test into next page lets say it is page2.aspx
You have to use like this
For a button click event
use session object
Session["your_session_variable_name"].ToString()=txt_user.Text;
 
and this will contains the text box value in session variable then you can use it in next page like this
String your_name=Session["your_session_variable_name"].ToString();
And now you can use this string till the session ends by default or you kill it
  Permalink  
Comments
riteshsingh_jsr at 17-Feb-13 12:23pm
   
exactly......
007alok at 18-Feb-13 3:10am
   
So you found your answer appropriately ?
riteshsingh_jsr at 18-Feb-13 6:15am
   
yes
Reza Nabiloo at 12-Mar-13 13:47pm
   
thank u so much dear friend. i understand completly
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You can add anything in a Session variable but you need to downcast it afterwards..
 
for example:
 

in ASP.NET
Session["object"] = anything
 
CODE BEHIND C#
anything x = (anything) Session["object"];
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
In another page, Session["userid"].ToString() returns the session variable "userid".
 
More information about Session: Exploring Session in ASP.NET[^]
 
Hope this helps.
  Permalink  
v3
Comments
Reza Nabiloo at 12-Mar-13 13:49pm
   
thank u so much dear friend.
ProgramFOX at 12-Mar-13 13:50pm
   
You're welcome!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

hii friend....
 
to take initial start with session then go to throw this link...
 
http://msdn.microsoft.com/en-us/library/75x4ha6s%28v=vs.100%29.aspx[^]
 
http://msdn.microsoft.com/en-us/library/03sekbw5%28v=vs.100%29.aspx[^]
 
thank you
  Permalink  
Comments
Reza Nabiloo at 12-Mar-13 13:47pm
   
thank u so much dear friend.
Shubh Agrahari at 13-Mar-13 10:35am
   
ma pleasure...but bad luck its down voted by someone

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

  Print Answers RSS
0 OriginalGriff 320
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 Sergey Alexandrovich Kryukov 184
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 18 Feb 2013
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