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. Advertisements

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. E11
    Replies:
    1
    Views:
    5,733
    Thomas Weidenfeller
    Oct 12, 2005
  2. Mantorok
    Replies:
    2
    Views:
    1,513
    Mantorok
    Jun 22, 2006
  3. Electric Co.
    Replies:
    2
    Views:
    616
    Teemu Keiski
    Aug 28, 2006
  4. Alf P. Steinbach
    Replies:
    6
    Views:
    808
    John Carson
    Sep 3, 2005
  5. Matt Winward
    Replies:
    0
    Views:
    497
    Matt Winward
    Mar 25, 2008
  6. Hicham Mouline
    Replies:
    1
    Views:
    822
    Victor Bazarov
    Apr 20, 2009
  7. Replies:
    2
    Views:
    223
    James Edward Gray II
    Mar 8, 2006
  8. Karan Rajput
    Replies:
    2
    Views:
    301
    Abinoam Jr.
    Dec 22, 2010
Loading...