I need to build user controls dinamically, is possible?

Discussion in 'ASP .Net Building Controls' started by leon, Oct 13, 2004.

  1. leon

    leon Guest

    Hello everybody.

    I need to build user controls dinamically into aspx page.

    Besides of this, i need to put into each userscontrol different controls,
    add to every control its control validators and its events.

    If someone has some idea, i will say Thanks a lot.

    leon
     
    leon, Oct 13, 2004
    #1
    1. Advertising

  2. "leon" <> wrote in message
    news:...
    > Hello everybody.
    >
    > I need to build user controls dinamically into aspx page.
    >
    > Besides of this, i need to put into each userscontrol different controls,
    > add to every control its control validators and its events.
    >
    > If someone has some idea, i will say Thanks a lot.


    You can dynamically "build" a custom server control. That is, you can create
    a custom control which dynamically decides which controls it will contain.

    It won't be a .ascx file, though.

    -----
    John Saunders
     
    John Saunders, Oct 13, 2004
    #2
    1. Advertising

  3. leon

    Sahil Malik Guest

    Leon,

    The answer is Page.LoadControl ... but keep reading ..

    This is a classic problem even framework 2.0 fails to solve appropriately.

    user controls are a combination of ascx and a code behind file in framework
    1.1 and a partial class and code beside class in framework 2.0. The way they
    work is, in 1.1 inherited code and in 2.0 combined code is compiled at
    runtime and an Activator.CreateInstance is called on the URL location of the
    ascx, similar to a webservice call .. it is like a server activated object.

    So while the ascx interface is fun to play with and intuitive, (etc. etc.),
    you cannot do a "new" on a usercontrol. ....

    HOWEVER .. you can do a Page.LoadControl :) which comes darned close.

    The only thing you cannot do is put UserControls along with ascx's in a dll
    and distribute that as a product. That is not possible to do :)

    - Sahil Malik
    You can reach me thru my blog at
    http://www.dotnetjunkies.com/weblog/sahilmalik



    "leon" <> wrote in message
    news:...
    > Hello everybody.
    >
    > I need to build user controls dinamically into aspx page.
    >
    > Besides of this, i need to put into each userscontrol different controls,
    > add to every control its control validators and its events.
    >
    > If someone has some idea, i will say Thanks a lot.
    >
    > leon
    >
    >
     
    Sahil Malik, Oct 13, 2004
    #3
    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. Rafi
    Replies:
    0
    Views:
    379
  2. vladvadeanu
    Replies:
    3
    Views:
    1,686
    Hans Kesting
    May 21, 2004
  3. =?Utf-8?B?Vmk=?=
    Replies:
    2
    Views:
    366
    Karl Seguin
    Nov 2, 2004
  4. Cesar Garcia H

    Really Creating dinamically Web Controls

    Cesar Garcia H, Feb 15, 2005, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    120
    Nick Stansbury
    Feb 22, 2005
  5. leon
    Replies:
    3
    Views:
    92
Loading...

Share This Page