modularbeing Posted June 30, 2004 Posted June 30, 2004 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! Quote
Administrators PlausiblyDamp Posted June 30, 2004 Administrators Posted June 30, 2004 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? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
modularbeing Posted June 30, 2004 Author Posted June 30, 2004 (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 June 30, 2004 by modularbeing Quote
Administrators PlausiblyDamp Posted July 1, 2004 Administrators Posted July 1, 2004 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
modularbeing Posted July 1, 2004 Author Posted July 1, 2004 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..... :( Quote
Administrators PlausiblyDamp Posted July 1, 2004 Administrators Posted July 1, 2004 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
modularbeing Posted July 1, 2004 Author Posted July 1, 2004 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.