Accessing viewstate from Component Object
-
Hello all, I have created a new object based on System.ComponentModel.Component and need to store information between postbacks. At the moment I am using Session, but really need to use the Page's Viewstate. However, I can't see a way to get access to the Page object. Can anyone tell me how this is done? (Or tell me its not possible!) Thanks for your assistance. Simon.
-
Hello all, I have created a new object based on System.ComponentModel.Component and need to store information between postbacks. At the moment I am using Session, but really need to use the Page's Viewstate. However, I can't see a way to get access to the Page object. Can anyone tell me how this is done? (Or tell me its not possible!) Thanks for your assistance. Simon.
while you can cast HttpContext.Current.Handler to System.Web.UI.Page, the ViewState is a protected property. You can't access it from a seperate component. You would be better off deriving from System.Web.UI.Control.
-
while you can cast HttpContext.Current.Handler to System.Web.UI.Page, the ViewState is a protected property. You can't access it from a seperate component. You would be better off deriving from System.Web.UI.Control.
Yeah, thats a good point. I forgot it was protected. :( Thanks for the info about casting the current http handler to a Page though - didn't realize I could do that. Unfortunately deriving from Control isn't an option at this stage. :( Thanks again, Simon.