Are you sure that your code is busting on your session variable when you try to assign it to the label? post a lot of your code so we can see what you're doing, please
Please post your code for us to help!!
Mark Answered if it helps - Good luck!
Cheers!
Design And Align - Rob
Are you sure that your code is busting on your session variable when you try to assign it to the label? post a lot of your code so we can see what you're doing, please
hmm.. Can I get 'yournode' from sender somehow in my code... keep in mind that we are seeing the value I need in the object or variable or whatever. Also I have tried to put it to a string variable not just label and it busts there too.
My apologies for wasting every1's time. I found that the Label I was using to display the value was being used elsewhere in my code and causing my error. So you guys were right all along, the code I had originally works as well as many of your suggestions.
Thanks for your time.
This code works:
// Set it on Masterpage
protected void sideNav_SelectedNodeChanged(object sender, EventArgs e)
{
Session["someValue"] = sideNav.SelectedNode.Value;
Response.Redirect("~/Account/Profile.aspx");
}
// Read it on other page and display it in Label1 in Page Load
if (Session["someValue"] != null)
{
Label1.Text = (string)(Session["someValue"]);
}
Don't stand in the fire...
Marked as answer by cool.asp on Mar 07, 2012 08:53 PM
cool.asp
Member
545 Points
190 Posts
Re: Session variable
Mar 07, 2012 06:32 PM|LINK
cool.asp
Member
545 Points
190 Posts
Re: Session variable
Mar 07, 2012 06:40 PM|LINK
I tried:
using System.Configuration; if (Session["someValue"] != null) { IDLabel.Text = ConfigurationManager.AppSettings["someValue"].ToString(); }But then I get the NullReferenceException "Object reference not set to an instance of an object" and I can still see the value in 'watch' ugggh
robwscott
Star
8079 Points
1491 Posts
Re: Session variable
Mar 07, 2012 06:46 PM|LINK
try
yourNode.SelectedNode.InnerText;
Are you sure that your code is busting on your session variable when you try to assign it to the label? post a lot of your code so we can see what you're doing, please
Mark Answered if it helps - Good luck!
Cheers!
Design And Align
- Rob
cool.asp
Member
545 Points
190 Posts
Re: Session variable
Mar 07, 2012 06:51 PM|LINK
robwscott
Star
8079 Points
1491 Posts
Re: Session variable
Mar 07, 2012 06:53 PM|LINK
no...yourNode = sideNav or whatever you called it
Mark Answered if it helps - Good luck!
Cheers!
Design And Align
- Rob
cool.asp
Member
545 Points
190 Posts
Re: Session variable
Mar 07, 2012 06:58 PM|LINK
Nope.
It says System.Web.UI.WebControls.TreeNode does not contain a definition for 'InnerText'. I don't see it intellisense.
cool.asp
Member
545 Points
190 Posts
Re: Session variable
Mar 07, 2012 08:52 PM|LINK
My apologies for wasting every1's time. I found that the Label I was using to display the value was being used elsewhere in my code and causing my error. So you guys were right all along, the code I had originally works as well as many of your suggestions. Thanks for your time.
This code works:
// Set it on Masterpage protected void sideNav_SelectedNodeChanged(object sender, EventArgs e) { Session["someValue"] = sideNav.SelectedNode.Value; Response.Redirect("~/Account/Profile.aspx"); } // Read it on other page and display it in Label1 in Page Load if (Session["someValue"] != null) { Label1.Text = (string)(Session["someValue"]); }