[quoted text, click to view] "XicoLoKo" <XicoLoKo@discussions.microsoft.com> wrote in message
news:BFE10C5D-F059-4D73-92A1-B0A51698926C@microsoft.com...
> Another approach would be to have a base usercontrol class, lets say
TitleBarChildControlBase, that exposes those properties from it's parent.
>
> User controls that inherit TitleBarChildControlBase would be used only
inside the TitleBar.
Ok, I originally read the OP as asking a question about user controls in
general. If, instead, the user controls in question will _always_ be used
inside of the same parent control, then knowing about their parent would be
ok.
In this case, it would be ok if the user controls were to cast their Parent
property to the type of the parent:
VB.NET:
Dim tbParentTitlebar As Titlebar = DirectCast(Parent, GetType(Titlebar))
' Can now use tbParentTitlebar.ListingType
C#:
Titlebar tbParentTitlebar = (Titlebar) Parent;
// Can now use tbParentTitlebar.ListingType
--
John Saunders
johnwsaundersiii at hotmail
[quoted text, click to view] > "John Saunders" wrote:
>
> > "Michael" <mwilson@nospam.raytheon.com> wrote in message
> > news:o0WIc.5$5c3.0@dfw-service2.ext.ray.com...
> > > We have a user control (Titlebar) that loads other user controls
> > (children)
> > > into itself based on a property set in the HTML:
> > >
> > > <fss:Titlebar id="empStmtListing" runat="server"
> > > UserControl="StatementListing.ascx" Width="90"
> > > HelpId="1" ListingType="3"></fss:Titlebar>
> > >
> > > Some of the children user controls need properties set to execute. We
> > would
> > > put these properties in the HTML of the parent,
> > > for example, the ListingType property above. Is there anyway that
> > > StatementListing.ascx can access and read the ListingType
> > > property? Or will our Titlebar user control always have to pass the
> > > properties into the child control?
> >
> > It's really bad form for a child control to know too much about its
parent.
> > Instead, let the parent tell the child what it needs to know.
> > --
> > John Saunders
> > johnwsaundersiii at hotmail
> >
> >
> >