Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Datagrid Control (http://www.velocityreviews.com/forums/f60-asp-net-datagrid-control.html)
-   -   Child property changes copied to parent? (http://www.velocityreviews.com/forums/t761988-child-property-changes-copied-to-parent.html)

lisa@starways.net 05-16-2005 02:40 PM

Child property changes copied to parent?
 
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


lisa@starways.net 05-16-2005 02:46 PM

Re: Child property changes copied to parent?
 
I'm sorry, this was posted to the wrong newsgroup. My apologies.
Followups set to
microsoft.public.dotnet.framework.aspnet.buildingc ontrols.

Lisa


l...@starways.net 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




All times are GMT. The time now is 06:58 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.