Access User Control Properties

I have a page that called Quote that works within a master page. On the Quote page, there are 10 instance of a QuoteItem UserControl, which within the Quote page, I need to loop through the UserControls public properties. See the code snippet

I can see the internal functions, but not the public properties which I don't understand in the intellisense, which makes m ething the public properties should also be visible. Maybe I am missing something here.

I've tried a number of things, but any property of obj is unknown.

What am I missing here?
John

Dim content As ContentPlaceHolder
        content = Page.Master.FindControl("ContentPlaceHolder1")
 
        Dim validItems As Boolean = True
 
 
        Dim basicPremium As Double = 0
        Dim overAgeLiability As Double = 0
        Dim overAgePremium As Double = 0
        Dim totalPrice As Double = 0
        Dim totalLoadsLowAttach As Double = 0
        Dim premium As Double = 0
 
        For x As Integer = 1 To 10
            Dim obj As UserControl = CType(content.FindControl("QID" & x.ToString), Quote_Sentry_QuoteItem)
 
            If obj.valid Then
                basicPremium = basicPremium + obj.BasicPremium
                overAgeLiability = overAgeLiability + obj.OverAgeLiability
                overAgePremium = overAgePremium + obj.OverAgePremium
                totalPrice = totalPrice + obj.TotalPrice
                totalLoadsLowAttach = totalLoadsLowAttach + TotalLoadsLowAttachment
                premium = premium + obj.FinalPremium
            Else
                validItems = False
                Exit For
            End If
        Next

Open in new window

LVL 1
WebGeeksUnlimitedAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
vb_jonasConnect With a Mentor Commented:
Ah, but that's an important change. Classical class confusion, easy to miss (I did also...). If an object is declared as a baseclass the compiler won't let us use the inherited class memebers, even if the object has them in memory. Using late binding we could have done it, but then it should be declared as Object.
0
 
zkeownCommented:
I think they have to be public static properties
0
 
vb_jonasCommented:
Yes, you should see all public members in intellisense. Did you try to rebuild web site?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
WebGeeksUnlimitedAuthor Commented:
In the UserControl, the properties are public, but do not appear in the intellisense and show unknown when you just type them in. See the snippet below.

I have tried to rebuild the site numerous times, it just does not understand the public properties.
Partial Class Quote_Sentry_QuoteItem
    Inherits System.Web.UI.UserControl
 
#Region "Global Variables"
    .
    .
    .
#End Region
 
#Region "Public Properties"
    Public Property Title() As String
        Get
            Return instanceTitle
        End Get
        Set(ByVal value As String)
            instanceTitle = value
        End Set
    End Property
 
    Public ReadOnly Property valid() As Boolean
        Get
            Return validACValues
        End Get
    End Property
 
    Public ReadOnly Property BasicPremium() As String
        Get
            Return zBasicPremium
        End Get
    End Property
 
    Public ReadOnly Property OverAgeLiability() As String
        Get
            Return zOverAgeLiability
        End Get
    End Property
 
    Public ReadOnly Property OverAgePremium() As String
        Get
            Return zOverAgePremium
        End Get
    End Property
 
    Public ReadOnly Property TotalPrice() As String
        Get
            Return zTotalPrice
        End Get
    End Property
 
    Public ReadOnly Property TotalLoadsLowAttachment() As String
        Get
            Return zTotalLoadsLowAttach
        End Get
    End Property
 
    Public ReadOnly Property FinalPremium() As String
        Get
            Return zPremium
        End Get
    End Property
#End Region
 
rest of code eliminated ...

Open in new window

0
 
WebGeeksUnlimitedAuthor Commented:
Well, I don't believe this .... after screwing around for two hours with this things, after work I went home and later in the evening I figured I would look at this again. Guess what, the public properties are now visible ... go figure.

I did one change however, but had done this several times and tried to rebuild the code as well.

Man, what a waste of two hours ... unreal
Dim obj As Quote_Sentry_Quoteitem = CType(content.FindControl("QID" & x.ToString), Quote_Sentry_QuoteItem)
 
instead of "As UserControl"

Open in new window

0
 
WebGeeksUnlimitedAuthor Commented:
The funny thing, I had already gone that route with the declaration as a class, which I found in another string on this site. But it still failed to work. Even accessing the object by it's actual ID exhibited the same behaviour.

I suspect there is some bug in VS2008, with prolonged use in one sitting, it looses it marbles and no matter what you do, some things don't work as you would think. It is not until you seem to restart VS or Windows XP that the IDE regains it senses.


 
0
 
vb_jonasCommented:
Could be, thats no fun, one should be able to rely on the compiler. I have noticed some behaviours like that in VS 2005 (w/o servicepacks), but 2008 is more stable in my opinion. In Vs2005 I needed to close and reopen solutions sometimes.
0
 
WebGeeksUnlimitedAuthor Commented:
The class declaration is the key thing and something I initially my self overlooked. But I was at one point on the right track, but VS2008 was brain dead and not doing the right thing. Others may get hosed on the IDE going in dummy land and think they are doing something wrong.

Moral of the story, if you really think your doing something the right way, try a recompile, if that does not work, restart VS2005/2008 and reboot to eliminate those quirks or you get sucked in as I did for two hours.

Thanks for the 2nd head here.
0
 
vb_jonasCommented:
Thanks for the points, and the closing thoughts. :)
0
 
WebGeeksUnlimitedAuthor Commented:
Your welcome and thanks for the 2nd head here :)
0
All Courses

From novice to tech pro — start learning today.