Dynamically Load Control from Control Library

Discussion in 'ASP .Net Web Controls' started by ShaunN, Dec 4, 2003.

  1. ShaunN

    ShaunN Guest

    I have created a number of web user controls within a Web Control Library called Blain.UQR.WebControls.

    I have a separate ASP.NET Web Application in which I want to use these controls. A reference to the Blain.UQR.WebControls dll is included in my ASP.NET Web Application project.

    The problem is that I cannot figure out how to dynamically load controls from the Blain.UQR.WebControls library.

    Of course, the standard way of dynamically including a user web control into a page is to use the LoadControl method. However, this takes the file name of the control as a parameter. For example:

    Dim ctl as Control
    ctl = LoadControl("/UserControls/myusercontrol.ascx")

    Since the web user controls are simply included in the project via a Reference to the Blain.UQR.Webcontrols dll, I do not know how I am supposed to dynamically load them, since the .ascx files are not available.

    Could anyone suggest how this might be done?

    Thanks a lot,
    Shaun
    ShaunN, Dec 4, 2003
    #1
    1. Advertising

  2. ShaunN

    Cy Huckaba Guest

    Hey Shaun,

    At this point what you have is a class that you have to instantiate and add to
    the page that you are working with.

    Basically, it should work like any other object. I would use a place holder
    control on the page that you will be adding the control to. Something like this.

    dim ctrl as New Blain.UQR.Webcontrols.ControlType

    'set props here if needed

    (placeholderid).controls.add(ctrl)

    That's it. That should do it.

    Cy Huckaba
    Austin, TX


    "ShaunN" <> wrote in message
    news:...
    > I have created a number of web user controls within a Web Control Library

    called Blain.UQR.WebControls.
    >
    > I have a separate ASP.NET Web Application in which I want to use these

    controls. A reference to the Blain.UQR.WebControls dll is included in my ASP.NET
    Web Application project.
    >
    > The problem is that I cannot figure out how to dynamically load controls from

    the Blain.UQR.WebControls library.
    >
    > Of course, the standard way of dynamically including a user web control into a

    page is to use the LoadControl method. However, this takes the file name of the
    control as a parameter. For example:
    >
    > Dim ctl as Control
    > ctl = LoadControl("/UserControls/myusercontrol.ascx")
    >
    > Since the web user controls are simply included in the project via a Reference

    to the Blain.UQR.Webcontrols dll, I do not know how I am supposed to dynamically
    load them, since the .ascx files are not available.
    >
    > Could anyone suggest how this might be done?
    >
    > Thanks a lot,
    > Shaun
    >
    Cy Huckaba, Dec 5, 2003
    #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. =?Utf-8?B?UmV6YSBOYWJp?=

    Load User Control Dynamically, Cast object dynamically

    =?Utf-8?B?UmV6YSBOYWJp?=, Mar 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    6,697
    Matt Berther
    Mar 5, 2005
  2. =?Utf-8?B?UmV6YSBOYWJp?=

    Load User Control Dynamically, Cast object dynamically

    =?Utf-8?B?UmV6YSBOYWJp?=, Mar 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    6,339
    Scott Allen
    Mar 4, 2005
  3. news.microsoft.com

    Load Web Control Library dynamically at runtime

    news.microsoft.com, Sep 3, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    162
    Brock Allen
    Sep 4, 2005
  4. Sammy
    Replies:
    1
    Views:
    293
    NET_NET_2003
    Aug 18, 2003
  5. Replies:
    1
    Views:
    72
    Martin Honnen
    Jun 30, 2005
Loading...

Share This Page