Session used in another page problem

asp.net Mauritius
  • 14 years ago

    Hi expert,

    I'm using session variable in one page and i want to retrieve this same session in another page. For example what i'm doing is:

    In frmSignup:(to take the session)

    lblAge.text= intAge

    Session ("Age")= lblAge.text

    In frm MyInfo: (where to retrieve the session)

    txtAge.text= " & session ("Age") &"

    I got the blue part as error. I'm trying to read from book to do it but with your experience perhaps i'll get the solution. Please Help.

     

  • 14 years ago

    Hi Vinay,

    If you want to create any new session then the syntax is:

    Session.Add("SessionName", Session Value)

    for eg.  Session.Add("Age", lblAge.Text)

    and at other web form , you need to write the following code to retrieve its value,

    i.e.  txtAge.Text = Session("Age")

     

    This will solve your problem.

     

    Regards,

    Chital

     

  • 14 years ago

    First of all try and follow all the language syntax correctly when you are coding

    If you have done so, then you need to have a look at the Types that are stored in these Session variables when you are retrieving them.

    For eg in C#,

    The value that you have stored in your Session variable by doing

    Session["Age"] =  txtAge.Text;

    would be retrieved correctly by casting it to the string type when retrieving it

    lblAge.Text = (string)Session["Age"];

  • 14 years ago

    Hi inferano & Vinay,

    I have posted answer which is syntax of VB.Net not C#.


    This is for your information.

     

    Regards,

    Chital

  • 14 years ago

    Hi Inferno & chital,

    Thanks a lot for both of you. Perhaps it was my mistake that I have not mentioned that I'm using VB codes. However Chital, I've tried your codes for the session yesterday night and found that its working perfectly. Thanks a lot.

  • 14 years ago

    Hi Vinay,

    Anytime..............Smiley Face [:)]

     

    Regards,

    Chital

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“If Java had true garbage collection, most programs would delete themselves upon execution.” - Robert Sewell