ViewState

J

JezB

How can I get to a page's ViewState from inside a business object ? I have a
reference to the calling page but the ViewState property of the Control
class is protected.

Is there something similar to HttpContext.Current.Session that allows a
business object to access the current Session ?
 
K

Kevin Spencer

How can I get to a page's ViewState from inside a business object ? I have
a
reference to the calling page but the ViewState property of the Control
class is protected.

Accessing private members from one class to another can be done by means of
creating public properties and methods that make changes to private members
from the inside.
Is there something similar to HttpContext.Current.Session that allows a
business object to access the current Session ?

System.Web.HttpContext.Current.Session

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
J

JezB

Kevin Spencer said:
have

Accessing private members from one class to another can be done by means of
creating public properties and methods that make changes to private members
from the inside.

I may have to resort to that, tho its not my ideal solution.
System.Web.HttpContext.Current.Session

No that's the same thing ! I meant something SIMILAR to this that would let
me get at ViewState.
 
K

Kevin Spencer

Ah, sorry. It's early. That would be

CType(System.Web.HttpContext.Current.Handler, System.Web.UI.Page).ViewState
(VB.Net)

- or -

((System.Web.UI.Page) System.Web.HttpContext.Current.Handler).ViewState (C#)

Note that this only makes the Page ViewState available. Each Control in the
Page has its own ViewState as well.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
K

Kevin Spencer

Oh yes, that is correct. You would have to expose the ViewState via a public
property in the Page in order to access it from another class.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top