MeghanOBrien
asked on
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?
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.Stat eBag viewstate)
{
_viewstate = viewstate;
}
public void DoSomething()
{
string s=(string)_viewstate["key" ];
}
}
This example initialize viewstate in constructor:
public class MyClass
{
protected System.Web.UI.StateBag _viewstate;
public MyClass(System.Web.UI.Stat
{
_viewstate = viewstate;
}
public void DoSomething()
{
string s=(string)_viewstate["key"
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can split the points if you want. It can be done in here. It is up to you. Goodluck with your projects. :-)
Public Class Separate
Inherits System.Web.UI.Page
End Class
You can then access ViewState within your class.
I hope this helps.