Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Child property changes copied to parent?

Thread Tools

Child property changes copied to parent?
Posts: n/a
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

<Browsable(False)> _
Public ReadOnly Property BackColor() As System.Drawing.Color
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
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?


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Property that mapped to a child control's property ? Samuel ASP .Net Building Controls 3 01-24-2006 06:18 AM
Child property changes copied to parent? ASP .Net Datagrid Control 1 05-16-2005 02:46 PM
Why do property changes in child controls get copied to the parent control? ASP .Net Building Controls 0 05-10-2005 01:49 PM
Custom Container Control Changes the Input Tag Names of Child Controls??? Chris Newby ASP .Net 1 02-25-2005 04:44 PM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM