Adding Controls to a Web Forms Page Programmatically

Discussion in 'ASP .Net Building Controls' started by mark.norgate@gmail.com, Mar 17, 2006.

  1. Guest

    Hi

    I'm having some trouble adding a user control to my webform
    programmatically. I've done this before, but not for some time.

    The control was rather complex, but I created a new one consisting of
    an <asp:Label> control just so I can see what's going on.

    I'm creating and adding the user control in my Page_Load method on my
    webform:

    private void Page_Load(object sender, System.EventArgs e) {
    ProjectDetailsControl projectDetails = new ProjectDetailsControl();

    // add the project to the project placeholder
    ProjectPlaceHolder.Controls.Add( projectDetails );

    // ...and so on
    }

    The Page_Load method of the user control is being called, but it's not
    rendering any HTML. I haven't made any modifications to anything else,
    including modifying the user control in any way besides dropping a
    label with some text onto it.

    What am I missing? Or have I done something I shouldn't?

    Help appreciated!

    Thanks, Mark
     
    , Mar 17, 2006
    #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. =?Utf-8?B?RCBTaGVsZG9u?=

    Adding validation controls programmatically

    =?Utf-8?B?RCBTaGVsZG9u?=, May 11, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    5,788
    =?Utf-8?B?RCBTaGVsZG9u?=
    May 11, 2004
  2. Tim Marsden

    Adding controls programmatically.

    Tim Marsden, May 19, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    575
    Steven Cheng[MSFT]
    May 25, 2004
  3. Chakravarti Mukesh

    Adding Controls Programmatically

    Chakravarti Mukesh, Jan 10, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    3,969
    brijesh patel
    Feb 14, 2013
  4. Leon
    Replies:
    3
    Views:
    1,579
    S. Justin Gengo
    Feb 12, 2010
  5. Jason Dunbar

    Programmatically Adding Web User Controls

    Jason Dunbar, Nov 8, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    127
    Jason Dunbar
    Nov 8, 2004
Loading...

Share This Page