views:

21

answers:

2

OK, I guess I'm missing something obvious here, but I still can't make it work...

I have a page in ASP.NET. I have a nested class inside the page. I have a property in this nested class. How can I access the page's viewstate from the property's Set statement?

Thanks!

A: 

Hey,

Viewstate is internal to the page; you would have to create a base page class with a public property exposing this.

Note: there is a reason why it's private :-) There are alternative stores for caching an object, and if an object is serializable, you can directly store the object in viewstate.

HTH.

Brian
A: 

What are you trying to do? You are probably going about it the wrong way. It sounds like the Page needs to set this property, not the "nested class" (By the way, this is entirely irrelevant to your problem). Is this just some arbitrary object? Or are we really talking about a user control or custom control?

If it's some arbitrary object... you will need to explicitly pass in the Page/Viewstate object as a method parameter, or expose a property which the Page can set.

Bryan