Child property changes copied to parent?

Discussion in 'ASP .Net Building Controls' started by lisa@starways.net, May 16, 2005.

  1. Guest

    I have a custom control that contains a collection. The collection is
    of another custom control.

    I can edit the child controls in a regular collection editor thing
    without problem. But when I do, any properties I change result in the
    new property being applied both to the child and to the parent control.

    And it doesn't seem to make any sense. I have this in the parent
    control:

    <Browsable(False)> _
    Public ReadOnly Property BackColor() As System.Drawing.Color
    Get
    Return System.Drawing.Color.Empty
    End Get
    End Property 'BackColor

    And I have this in the child control:

    <Browsable(True), NotifyParentProperty(False)> _
    Public Property BackColor() As System.Drawing.Color
    Get
    Return _backColor
    End Get
    Set(ByVal Value As System.Drawing.Color)
    _backColor = Value
    End Set
    End Property 'BackColor

    I don't even want the parent control to *have* a BackColor property.
    But when I set the BackColor on one of the children, that same property
    is applied to the parent. It doesn't render, because of the Return
    Color.Empty, but it's there in the aspx page. And since the same thing
    happens with Enabled, which I *do* want working on both the parent and
    the children, this is a real problem.

    I tried adding the NotifyParentProperty(False) attribute to the
    property, thinking that it would prevent this from happening. It
    didn't. I tried adding that attribute to the child control's class
    declaration, and it wouldn't allow it.

    Has anyone else run into something like this? Is there any way to stop
    it from happening?

    Thanks,
    Lisa
     
    , May 16, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Rodriguez
    Replies:
    23
    Views:
    1,211
    David Schwartz
    Dec 9, 2003
  2. Replies:
    0
    Views:
    137
  3. Child property changes copied to parent?

    , May 16, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    137
  4. Noel Dolan
    Replies:
    0
    Views:
    276
    Noel Dolan
    Jul 18, 2004
  5. Bitswapper
    Replies:
    5
    Views:
    184
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page