By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,969 Members | 1,564 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,969 IT Pros & Developers. It's quick & easy.

problems using CompositeControl base class

P: n/a
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

Jun 2 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.