User controls and LoadControl method

Discussion in 'ASP .Net Web Controls' started by J055, Oct 3, 2006.

  1. J055

    J055 Guest

    Hi

    I need to send parameters to a user control contructor. Is this what the
    TemplateControl.LoadControl (Type, Object[]) is for? If so can someone show
    me how to use it please?

    This is my attempt so far but I get a MissingMethodException - Constructor
    on type '*' not found. The control would be loaded twice anyway. Hopefully
    you can see what I'm trying to achieve.

    Control myCtrl = LoadControl("~/Controls/myCtrl.ascx");
    PlaceHolder ph = (PlaceHolder)fv.FindControl("ph");
    ph.Controls.Add(LoadControl(myCtrl.GetType(), new object[] { myobj }));
    ph.Visible = true;

    Many thanks
    Andrew
    J055, Oct 3, 2006
    #1
    1. Advertising

  2. Hello Andrew,

    If you need to send parameters to a user control, you may consider created
    customized public property for the user control, and set the property right
    after you create/load it.

    Sincerely,

    Luke Zhang

    Microsoft Online Community Support
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Luke Zhang [MSFT], Oct 5, 2006
    #2
    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. Jonel Rienton
    Replies:
    2
    Views:
    4,868
    Jonel Rienton
    Nov 24, 2003
  2. Jeremy
    Replies:
    2
    Views:
    5,772
    Jeremy
    Jun 24, 2004
  3. Umut Tezduyar
    Replies:
    10
    Views:
    790
    Umut Tezduyar
    Nov 29, 2004
  4. lennart
    Replies:
    1
    Views:
    470
    lennart
    Apr 25, 2010
  5. Deane
    Replies:
    0
    Views:
    862
    Deane
    Sep 3, 2007
Loading...

Share This Page