Reputation: 1251
I'm setting a session variable in the master page in the Page_Init event. I then have a property on the master page that allows me to access that value.
Code on master page:
public Eco.Business.User User
{
get { return (Eco.Business.User)Session["user"];}
set { _user = value; }
}
I then do this in the page load event of a page that uses the master page (class for the master page is SiteMaster).
SiteMaster m = new SiteMaster();
Eco.Business.User _user = new Eco.Business.User();
_user = m.User;
Can figure out why the property in the master page is not being set. It is always null. But the session Session["user"] has something. I know this because I saw it in the debugger. Any ideas?
Thank you
Upvotes: 0
Views: 74
Reputation: 10950
If I understand what you're trying to accomplish, I think you will want to set the object in the Session in the property definition as well:
public Eco.Business.User User
{
get { return (Eco.Business.User)Session["user"];}
set { Session["user"] = value; }
}
Upvotes: 2