problems using CompositeControl base class

Discussion in 'ASP .Net' started by Steve Richter, Jun 2, 2007.

  1. 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
    Steve Richter, Jun 2, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mantorok
    Replies:
    2
    Views:
    1,366
    Mantorok
    Jun 22, 2006
  2. Alf P. Steinbach
    Replies:
    6
    Views:
    531
    John Carson
    Sep 3, 2005
  3. Matt Winward
    Replies:
    0
    Views:
    369
    Matt Winward
    Mar 25, 2008
  4. Hicham Mouline
    Replies:
    1
    Views:
    580
    Victor Bazarov
    Apr 20, 2009
  5. Karan Rajput
    Replies:
    2
    Views:
    129
    Abinoam Jr.
    Dec 22, 2010
Loading...

Share This Page