Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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..

 

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!

Posted (edited)
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"

Edited by modularbeing
  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
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..... :(
  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...