CreateChildControls() when adding controls programmatically

Discussion in 'ASP .Net' started by mark.norgate, Jun 19, 2006.

  1. mark.norgate

    mark.norgate Guest

    Righto, a problem with programmatically created controls.

    Well, in that kind of area anyway. I'm creating and adding controls to
    my page using TemplateControl.LoadControl quite successfully, but I
    have a button on my page that adds another control (it's a row of a
    table in a timesheet application).

    Trouble is, of course, CreateChildControls() is called before
    AddProject(), which is the method that adds another row to the table. I
    could add this row to the table in AddProject(), but that seems to be
    moving the logic of creating controls out of the CreateChildControls()
    method where it belongs; or am I just being pedantic?

    Have looked at the page lifecycle documentation in the MSDN stuff, but
    there's no real explanation of how to handle this kind of thing.

    Any explanations, or preferably links, would be greatly appreciated.

    mark.norgate, Jun 19, 2006
    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.