CreateChildControl vs RenderContents

Discussion in 'ASP .Net Web Controls' started by Paul S, Feb 22, 2010.

  1. Paul S

    Paul S Guest

    I'm creating a Custom Server Control
    public class DataFormControl : CompositeControl, INamingContainer

    The controls are added dynamically depending on the values set on the

    Do I need to go through my logic to determine what controls to add twice -
    first when I create the controls in CreateChildControls and the in
    RenderContent to render the controls?

    or am I just of track here?.

    I would appreciate some clarification

    Paul S
    Paul S, Feb 22, 2010
    1. Advertisements

  2. Paul S

    Hemant Guest

    You can either use CreateChildControls or Rendercontaint.
    if you want to use child controls you can use createchild controls(other
    controls like textbox etc) or you want to dynamically output html then use

    Hemant, Feb 23, 2010
    1. Advertisements

  3. Paul S

    Paul S Guest

    If I do this nothing gets rendered - what do I need to do also?

    PlaceHolder ph;
    protected override void CreateChildControls()
    base.CreateChildControls(); = new PlaceHolder();

    TextBox tb = new TextBox();
    tb.Text = this.Text;
    Button bt = new Button();
    bt.Text = "Click";


    protected override void RenderContents(HtmlTextWriter writer)
    Paul S, Feb 23, 2010
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.