I can't write Page.ViewState

T

Tony

Hello!

The reason I can't write Page.ViewState must depend on that ViewState
property is defined as protected so
must be accessed from a class that is derive from the Page class.
The normal way to access ViewState from within the Default class below is to
write
this.ViewState or just ViewState.
Is my understanding correct ?
public partial class Default : System.Web.UI.Page

//Tony
 
A

Arne Vajhøj

The reason I can't write Page.ViewState must depend on that ViewState
property is defined as protected so
must be accessed from a class that is derive from the Page class.
The normal way to access ViewState from within the Default class below
is to write
this.ViewState or just ViewState.
Is my understanding correct ?
public partial class Default : System.Web.UI.Page

ViewState has protected access. The semantics of protected access
are well known.

Note that the property only has a get not a set. You can not
replace the bag - only add items to it or remove items from it.

Arne
 
A

Arne Vajhøj

The reason I can't write Page.ViewState must depend on that ViewState
property is defined as protected so
must be accessed from a class that is derive from the Page class.
The normal way to access ViewState from within the Default class below is to
write
this.ViewState or just ViewState.
Is my understanding correct ?
public partial class Default : System.Web.UI.Page

I am wondering about that also. I want to kill my session when my
msgProcessor class receives the logout message, but Session[] and
Application[] do not seem to be accessible, so I am thinking of
returning a special value to it. Adding a public method might be
another option.

The session object has among other the following two methods:
Clear
Abandon

One of them may do what you want.

Arne
 

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

Top