Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ViewState property can not be accessed in derived class ???

Reply
Thread Tools

ViewState property can not be accessed in derived class ???

 
 
Chris Peeters
Guest
Posts: n/a
 
      08-10-2007
Hi,

Using inheritance, doesn't 'protected' mean that derived classes can
access that data if specified as protected in the base class ?

Aparently not: ViewState property is declared as protected in the
Control class. ListBox inherits (indirectly) from Control but the
ViewState property can not be accessed ???

It generates following compiler error :
"Cannot access protected member
'System.Web.UI.Control.ViewState' via a qualifier of type
'System.Web.UI.WebControls.ListBox'; the qualifier must be of
type 'PageCounter' (or derived from it)"

How come ?

Thank you
Chris

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Brett Wiltshire
Guest
Posts: n/a
 
      08-10-2007
On 10 Aug, 11:30, Chris Peeters <(E-Mail Removed)> wrote:
> Hi,
>
> Using inheritance, doesn't 'protected' mean that derived classes can
> access that data if specified as protected in the base class ?
>
> Aparently not: ViewState property is declared as protected in the
> Control class. ListBox inherits (indirectly) from Control but the
> ViewState property can not be accessed ???
>
> It generates following compiler error :
> "Cannot access protected member
> 'System.Web.UI.Control.ViewState' via a qualifier of type
> 'System.Web.UI.WebControls.ListBox'; the qualifier must be of
> type 'PageCounter' (or derived from it)"
>
> How come ?
>
> Thank you
> Chris
>
> *** Sent via Developersdexhttp://www.developersdex.com***


Hi Chris,

Are you writing a derived class?

Perhaps you could post some code to clarify the problem you're having?


Brett.

 
Reply With Quote
 
 
 
 
Chris Peeters
Guest
Posts: n/a
 
      08-10-2007
Hello,

I just try to type in Page_Load()

lstColors.ViewState["test"] = 0;

with lstColors defined as a normal asp-ListBox.

ViewState is the inherited property.

but I realised what i am doing wrong:

I try to access the listbox-protected property from a different class,
page-class , which is not allowed of course !
Page class can only access its own inherited ViewState-property.

thanks anyway
Chris

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Derived::Derived(const Base&) and Derived& operator=(const Base&) developereo@hotmail.com C++ 1 05-23-2007 01:44 PM
Derived::Derived(const Base&) and Derived& operator=(const Base&) developereo@hotmail.com C++ 1 05-23-2007 12:07 AM
very intersting:derived class private member accessed??? Bangalore C++ 3 06-23-2006 03:40 PM
system property not accessed by third-party application crash.test.dummy Java 0 03-15-2006 11:21 PM
Is this valid C++ (protected member of base accessed in derived class function) Shelly Adhikari C++ 3 09-10-2003 08:18 PM



Advertisments