Child property changes copied to parent?

Discussion in 'ASP .Net Datagrid Control' 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, thinking that
    it would prevent this from happening. It didn't.

    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

  2. Guest

    I'm sorry, this was posted to the wrong newsgroup. My apologies.
    Followups set to
    microsoft.public.dotnet.framework.aspnet.buildingcontrols.

    Lisa


    wrote:
    > 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, thinking

    that
    > it would prevent this from happening. It didn't.
    >
    > Has anyone else run into something like this? Is there any way to

    stop
    > it from happening?
    >
    > Thanks,
    > Lisa
    , May 16, 2005
    #2
    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,084
    David Schwartz
    Dec 9, 2003
  2. Replies:
    0
    Views:
    120
  3. Child property changes copied to parent?

    , May 16, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    108
  4. Noel Dolan
    Replies:
    0
    Views:
    216
    Noel Dolan
    Jul 18, 2004
  5. Bitswapper
    Replies:
    5
    Views:
    119
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page