Viewstate in a Class

V

Vik

Is it possible to access Page.Viewstate() from some class method that gets a
Web control from this page as a parameter?
I get an error message that Viewstate is protected.

Thanks.
 
A

Alvin Bruney [ASP.NET MVP]

You'll likely run into problems because the class is not really in sync with
the page life cycle. For instance, when you instantiate your class, do
something and then try to push back to the page, it may not be there, it
could have already left for the client. Or it could be serviced on another
thread entirely depending on how you structure the page. Anyway, what you
are trying to get to is most likely the current request and not the page
itself. In that case, use context.current

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Download OWC Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $15.00
Need a free copy of VSTS 2008 w/ MSDN Premium?
http://msmvps.com/blogs/alvin/Default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top