473,324 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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 ***
Aug 10 '07 #1
2 3594
On 10 Aug, 11:30, Chris Peeters <cmr...@yahoo.comwrote:
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.

Aug 10 '07 #2
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 ***
Aug 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Christian | last post by:
Hi, Viewstate of WebUserControl does NOT work although the 'EnableViewstate'-property of the usercontrol is set to true Description : Using ASP.Net : I have a created a WebPage with 2...
2
by: Christian | last post by:
Hi, Viewstate of WebUserControl does NOT work although the 'EnableViewstate'-property of the usercontrol is set to true Description : Using ASP.Net : I have a created a WebPage with 2...
8
by: Jeronimo Bertran | last post by:
I have an aspx page that saves some information using the ViewState. This page has an IMG META that uses a second aspx page to render the image. <IMG src= "ImageRender.aspx"> I noticed that...
0
by: John Crowley | last post by:
I'm having an odd problem with viewstate and a dynamically created control inside a repeater template. Basically, I have a repeater setup like this in the aspx:
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
1
by: 234 | last post by:
I'm playing around with page inheritence and I'm to the point now where I want to create a form object on a derived page. Here's a truncated version of my 'base' page from which all/most pages in...
9
by: Mark Broadbent | last post by:
Been a while since I've touched asp.net but one thing that always seems to fustrate me is the loss of state on variable declarations. Is there anyway (i.e. assigning an attribute etc) to instruct...
3
by: Bangalore | last post by:
Hi, In the following program, eventhogh two member function declared under private section of the derived class are accessable by derived class pointer. Please clarify me how can derived class...
1
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I want to confirm my understanding about access modifier for property. Assembly One contains: Class One has Protected property Protected1_prop Class Two has Friend property Friend2_prop Class...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.