|
|
|
start date: Fri, 10 Aug 2007 03:30:57 -0700,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
Chris Peeters
|
|
2
Brett Wiltshire
|
|
3
Chris Peeters
|
ViewState property can not be accessed in derived class ???
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 ***
Date:Fri, 10 Aug 2007 03:30:57 -0700
Author:
|
Re: ViewState property can not be accessed in derived class ???
On 10 Aug, 11:30, Chris Peeters 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.
Date:Fri, 10 Aug 2007 03:39:18 -0700
Author:
|
Re: ViewState property can not be accessed in derived class ???
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 ***
Date:Fri, 10 Aug 2007 05:11:51 -0700
Author:
|
|
|