I have a page that I store a value in the ViewState and I want to get this ViewState value in a User Control that I have. How do I do this. Seems like something basic but I can not get it to work. In the code behind page for the parent I set the viewstate like
so -> ViewState["color"] = "blue"; How do I get this value in a user control that I am using in my parent page? Thanks in advance, George
Page and user control have separate ViewState collections (every control has its own ViewState collection) so you can't set value in Page's ViewState collection and get it in user control's. Instead, you could create a public property in the user control that
the page can then access that means read/set and that way provide the data for the UC.
sinclairgf
Member
108 Points
44 Posts
Get Parent ViewState in User Control
Aug 21, 2003 02:03 PM|LINK
joteke
All-Star
46284 Points
6896 Posts
ASPInsiders
MVP
Re: Get Parent ViewState in User Control
Aug 21, 2003 07:38 PM|LINK
Teemu Keiski
Finland, EU
sinclairgf
Member
108 Points
44 Posts
Re: Get Parent ViewState in User Control
Aug 21, 2003 09:05 PM|LINK