Problem with properties

modularbeing

Regular
Joined
Jan 8, 2004
Messages
63
I created a usercontrol with 3 nested classes inside it and inside the third class I have a public property. I am able to access public variables in the base class but I cannot access public variables or public properties inside the nested classes. below is how I have them structured..

Code:
Public Class NameGroup
Inherits System.Web.UI.UserControl
      Public MustInherit Class Validators
            Public MustInherit Class FirstName
                Public MustInherit Class RequiredField
                   
                    Inherits NameGroup
                    Public Property Enabled() As Boolean
                        Get
                            Enabled = Me.valReqFName.Enabled()
                        End Get
                        Set(ByVal Value As Boolean)
                            Me.valReqFName.Enabled = Value
                        End Set
                    End Property
                
                   End Class
             End Class
      End Class
End Class

thanks for your input!
 
PlausiblyDamp said:
When you say you can't access public variables from the nested classes what errors do you get? Could you post the code where you are trying to access them?

I shouldnt say access....I dont see it in the intellisense?(not sure if thats the name for it) when i access the classes. unless properties are not supposed to show there, i thought that they did.

thanks

EDIT: I just tried putting 'enabled' at the end and it allows me to set it but I get a blue underline which notes the following: "reference to a non-shared member requires an object reference"
 
Last edited:
If you are accessing a nested class' property then you will need to put the full "path" to the property by also referencing each of the nested classes in turn.

Is there a particular reason why you are using nested classes in this scenario? It looks like either interfaces or inheritance may be a better solution.
 
Well for this project im working on I thought I would create a custom namespace for doing the database inserts and I am building usercontrols and wanted to integrate it all into one dll. So I havnt really done anything like this before. I am still kinda new to inheritance and I do not know what interfaces do..... :(
 
Namespaces can be used to organise code without needing to nest classes, also dlls can contain many seperate classes without the need to nest them.
It may be easier if you explain what you are trying to do / ideas so far and see what people out here think.
 
there are two parts to the namespace I want to make, Database and UI. under the database I want to have grouped into more specific sub namespaces for each item(parameter) to be inserted into the database. and I will have a sub for execute_insert which will look at all the information given and decide what stored procedures to call and insert the data. under the UI section I want to be able to call the user controls I made so I can insert them onto the pages. I also want to be able to control certain aspects of the usercontrols such as how the validators work and changing the enabled properties to some controls within the usercontrol.......

thanks
 
Back
Top