Search code examples
c#asp.netviewstate

Modifying ViewState from Class Library


I was supposing that accessing to viewstate from a class in a separate class library is similar to session, application and cache object. But I checked HttpContext class and I found to entry for viewstate. I'm looking for a way to organize the way I use viewstate in my web app and I want to make a class that handles these kinds of operations.

I also checked the questions tagged with the viewstate label in SO and I found no similar questions. Would you please telling me how can I access/reference viewstate object from a separate class library?


Solution

  • The ViewState property belongs to the Control class, we always use the one from Page : Control.

    The Page has the decoded Viewstate. You could get at the Base64 text through HttpContext.Current.Request but that's of little use.