Get ViewState in a .VB class file

I need to get viewstate but I am not in a code behind file, I am in a separate class file.  Is it possible?  If so, how?
MeghanOBrienAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alfred A.Commented:
You can try to inherit the page class in your separate class file.

Public Class Separate
       Inherits System.Web.UI.Page

End Class

You can then access ViewState within your class.

I hope this helps.
0
badalpatelCommented:
You can store a viewstate in  your class variable, and then use it when you need.
This example initialize viewstate in constructor:

      public class MyClass
      {
            protected System.Web.UI.StateBag _viewstate;
            public MyClass(System.Web.UI.StateBag viewstate)
            {
                  _viewstate = viewstate;
            }

            public void DoSomething()
            {
                  string s=(string)_viewstate["key"];
            }
      }
0
MeghanOBrienAuthor Commented:
I apologize, I went a different way and no longer need viewstate.  Didn't get a chance to try out these solutions, I don't know if I can split the points or what?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Alfred A.Commented:
You can split the points if you want.  It can be done in here.  It is up to you.  Goodluck with your projects. :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.