How to get viewstate from codebehind?

  • Thread starter Thread starter Sebastian
  • Start date Start date
S

Sebastian

I have class file. How can I get viewstate from it? for session or
request I use for ex. HttpContext.Current.Session. How can I do it for
viewstate in c#?

Sebastian
 
I want to retrive simple string value which I put, not object property. Just
simple string.

Sebastian
 
Cast the object in view state to the type that you need it to be.

string strColor;
strColor =(string)ViewState["color"];

Or

Dim strColor as String
strColor = CStr(ViewState("color"))

Dmitri
 
Page.ViewState["itemName"].ToString() should do the trick.

Jay Nathan, MCP .NET
Senior Consultant
MARINER
 
Page.ViewState["itemName"].ToString() should do the trick.

Thx, but...
In login.aspx.cs I create object from class which is in other namespace and
other file.

I create object in "login.aspx.cs"file from class that is
in"components/login.cs" file.
Now, the question is: how can I get to viewstate from file login.cs in
components folder?
 
Demyanik Dmitri said:
Cast the object in view state to the type that you need it to be.

string strColor;
strColor =(string)ViewState["color"];

Thx, but...
In login.aspx.cs I create object from class which is in other namespace and
other file.

I create object in "login.aspx.cs"file from class that is
in"components/login.cs" file.
Now, the question is: how can I get to viewstate from file login.cs in
components folder?
 
Back
Top