ASP.NET using C# Help using Sessions :(

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CharlesHawk
    New Member
    • Jul 2007
    • 8

    ASP.NET using C# Help using Sessions :(

    HI i am working on a Project
    where i have to send a string using Sessions["creditcard NR"]
    to the next page this is working gud for now
    But i can convert session["creditcard nr"] to a string the .ToString();
    and the Convert.ToStrin g(.....); is not workin

    I am using Web Matrix .

    Please Help me ASAP. tanx

    here is some code

    public void Page_Load(Objec t sender,EventArg s evt)
    {
    if(Session["AccNR"] == null)
    Response.Redire ct("Home.aspx") ;
    Response.Write( Session["AccNR"]);
    lblAccNR.Text = Session["AccNR"].ToString(); //<- Error ?
    }
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    moved to .NET forum. You might get more help here.

    Jared

    Comment

    • TRScheel
      Recognized Expert Contributor
      • Apr 2007
      • 638

      #3
      Anything saved in the session is saved as an object. To retrieve it you need to cast it to string.

      Code:
      lblAccNR.Text = (string)Session["AccNR"];

      Comment

      Working...