problems using CompositeControl base class

S

Steve Richter

my composite control does not render correctly the 2nd time it is made
visible. When I change the base class from CompositeControl to
WebControl, the control works as it should.

public class RowPrompt2 : System.Web.UI.WebControls.WebControl,
INamingContainer
// public class RowPrompt2 :
System.Web.UI.WebControls.CompositeControl, INamingContainer
{
}

In CreateChildControls I clear controls, create a Panel control, then
create controls within the Panel.
protected override void CreateChildControls()
{
Controls.Clear();
...
}

when I switch to WebControl as the base class I have to comment out
the RecreateChildControls method:
// protected override void RecreateChildControls()
// {
// EnsureChildControls();
// }

In Render, I let the base class do the work:
protected override void Render(HtmlTextWriter InWriter)
{
base.Render(InWriter);
}

that is it. no other methods are overridden.

what is happening is, when the control is made visible the 2nd time,
the Panel which contains a series of Label, TextBox pairs followed by
two Buttons, is rendered with one label and a button with the text
value of one of the Labels.

I dont see what I could be doing wrong since when I change to the
WebControl base it renders correctly. Do I get a prize for finding a
bug in CompositeControl, or am I the one with the bug?

thanks,

-Steve
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top