Child Controls disappear when changing properties of parent control

Child Controls disappear when changing properties of parent control

Post by Mike Co » Fri, 14 Feb 2003 05:22:38



I know I'm missing something here.
I've created a custom Web Control and I am trying to create child
controls in it. When I create child controls in it (I know of the
whole ReadWriteControlDesigner issue, so all child controls are
created on the html side) the design view renders ok. But when I click
on the custom control, change a property and go back to the html view,
the child controls have disappeared! Only the custom control's opening
and closing tags remain. The weird thing is that the design view still
shows the child controls (since I RenderChildControls() in the custom
controls Render method).

I have the PersistChildren(true) tag at the top of the custom control,
and I call EnsureChildControls() in all of the get/set methods and at
the beginning of the Render method.

What am I missing?

Thanks

 
 
 

Child Controls disappear when changing properties of parent control

Post by Teemu Keisk » Mon, 17 Feb 2003 06:04:34


Have you derived your control from WebControl or Control? Post some code
also.

In addition to have PersistChildren(true) so that designer persists inner
content as child controls, you probably should have ParseChildren(false) so
that content is parsed as child controls?
--
Teemu Keiski
Designer/Developer,Mansoft tietotekniikka Oy
http://www.mansoft.fi

ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com
Member of AspElite team, www.aspelite.com

Email:



Quote:> I know I'm missing something here.
> I've created a custom Web Control and I am trying to create child
> controls in it. When I create child controls in it (I know of the
> whole ReadWriteControlDesigner issue, so all child controls are
> created on the html side) the design view renders ok. But when I click
> on the custom control, change a property and go back to the html view,
> the child controls have disappeared! Only the custom control's opening
> and closing tags remain. The weird thing is that the design view still
> shows the child controls (since I RenderChildControls() in the custom
> controls Render method).

> I have the PersistChildren(true) tag at the top of the custom control,
> and I call EnsureChildControls() in all of the get/set methods and at
> the beginning of the Render method.

> What am I missing?

> Thanks


 
 
 

Child Controls disappear when changing properties of parent control

Post by Tim » Wed, 19 Feb 2003 22:34:45


I'm having the same problem.  I've searched every
resource I can find and no progress.  Please post if you
find a solution.

Thanks
Tim

Quote:>-----Original Message-----
>I know I'm missing something here.
>I've created a custom Web Control and I am trying to
create child
>controls in it. When I create child controls in it (I
know of the
>whole ReadWriteControlDesigner issue, so all child
controls are
>created on the html side) the design view renders ok.
But when I click
>on the custom control, change a property and go back to
the html view,
>the child controls have disappeared! Only the custom
control's opening
>and closing tags remain. The weird thing is that the
design view still
>shows the child controls (since I RenderChildControls()
in the custom
>controls Render method).

>I have the PersistChildren(true) tag at the top of the
custom control,
>and I call EnsureChildControls() in all of the get/set
methods and at
>the beginning of the Render method.

>What am I missing?

>Thanks
>.

 
 
 

1. Changing properties on child controls when the parent's property changes...

Hi all,

I've got a control that contains some child controls. When the Font property
of the parent control changes, I'd like it to propogate down to the child
controls. I overrode the OnFontChanged event in my parent control to look
like this:

    Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
        Dim c As Control

        For Each c In Me.Controls
            c.Font = Mybase.Font
        Next
        MyBase.OnFontChanged(e)
    End Sub

It doesn't seem to work in design-time or run-time. What am I doing wrong?

Thanks,

Tim

2. monitor compatability

3. How to control the Parent Web Page Controls from the Child Web Control

4. PSAPI.DLL Installation

5. How can a parent control draw on child controls?

6. \section in letter.sty

7. Adding a Web Control to a 3rd Party Control (Parent / Child?)

8. Parent server control deletes child controls?

9. Control change property of another control

10. Can you change the property of a user control (.ascx) from a control (.dll)?

11. Compound Control as Parent Control / ParentControlDesigner / Controls Collection