Creating controls at runtime or designtime

Discussion in 'ASP .Net' started by Varangian, Apr 26, 2006.

  1. Varangian

    Varangian Guest

    Hello

    is creating controls at runtime the same as designtime ?

    will a page be faster if controls are created at designtime rather than
    at runtime ? If so why ?

    thanks :)
     
    Varangian, Apr 26, 2006
    #1
    1. Advertising

  2. I personally do not agree that there will be any performance difference
    between design time controls and the server side controls executed by
    ASP.NET/.NET.

    Ultilmately, all controls has to be allocated at runtime and executed.


    The differences may vary in use. Design time controls are easy to use,
    matainence, where as dynamic controls are flexibile but should manually
    maintain the view state persitence, child controls, etc.

    If designed for specific functionality, dynamic controls can be
    designed to provide faster access and/or with less memory footprint.

    This can be a topic of contreversy but I prefer to distingush this way.

    Hth,
    Aru
     
    Arundhati Anavekar, Apr 26, 2006
    #2
    1. Advertising

  3. Varangian

    Varangian Guest

    thanks for the reply :)

    I wish more would comment on this
     
    Varangian, Apr 26, 2006
    #3
  4. Varangian

    Jeff Dillon Guest

    Test and see for yourself??

    "Varangian" <> wrote in message
    news:...
    > thanks for the reply :)
    >
    > I wish more would comment on this
    >
     
    Jeff Dillon, Apr 26, 2006
    #4
  5. I agree with Arundhati.
    Performance is not the main reason to go with design time controls because
    there is little to no difference in performance.
    Maintainability is the prime reason to go with design time controls whenever
    possible - except maybe for unusually gigantic projects.
    The code for creating and working with controls at runtime is much more
    complex than the drag and drop simplicity of design time control editing.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net



    "Varangian" <> wrote in message
    news:...
    > Hello
    >
    > is creating controls at runtime the same as designtime ?
    >
    > will a page be faster if controls are created at designtime rather than
    > at runtime ? If so why ?
    >
    > thanks :)
    >
     
    Steve C. Orr [MVP, MCSD], Apr 26, 2006
    #5
  6. all controls are created at runtime. when the page is compiled, the compiled
    code is just statments to create the controls at runtime.

    take simple page:

    <html>
    <body>
    <form runat=server>
    <asp:button id=submit runat=server>
    </form>
    </body>
    </html>

    when the page is compiled, the init code for the page class will contrain
    code like:

    HtmlGenericControl ctl;
    ctl = new HtmlGenericControl();
    ctl.InnerHtml = "<html><body>";
    Page.Controls.Add(ctl);
    Form frm = new Form()
    Button btn = new Button()
    btn.Name = "submit";
    frm.Controls.Add(btn);
    Page.Controls.Add(frm);
    ctl = new HtmlGenericControl();
    ctl.InnerHtml = "</body></html>";
    Page.Controls.Add(ctl);

    -- bruce (sqlwork.com)




    "Varangian" <> wrote in message
    news:...
    > Hello
    >
    > is creating controls at runtime the same as designtime ?
    >
    > will a page be faster if controls are created at designtime rather than
    > at runtime ? If so why ?
    >
    > thanks :)
    >
     
    bruce barker \(sqlwork.com\), Apr 26, 2006
    #6
  7. There will be a very slight difference ...

    I will not call them "Design Time" controls as they can also be setup in
    html by hand and the same items here apply.

    As Bruce points out, eventually the page is converted into a form that is
    dynamically creating controls (it generates a class representing the work to
    be done).

    When you are dealing with dynamic controls in the code behind, the
    compilation has already been done and is in your .dll, therefor the first
    time the page is hit a compilation of that information is not needed. Of
    course ASP.NET caches this information for the second time the page is hit
    so this difference only really applies the first time the page is hit.

    The fact that it is compiled as does also offer some benefits. You can
    change code in the .aspx (.ascx) and it will be recompiled on the next page
    hit as opposed to having to recompile the entire application.

    As for maintainability I would lean towards the dynamic controls as many
    techniques can be applied to them that cannot be applied to html based
    controls (example: design patterns such as factory and decorator).

    Cheers,

    Greg

    "Arundhati Anavekar" <> wrote in message
    news:...
    >I personally do not agree that there will be any performance difference
    > between design time controls and the server side controls executed by
    > ASP.NET/.NET.
    >
    > Ultilmately, all controls has to be allocated at runtime and executed.
    >
    >
    > The differences may vary in use. Design time controls are easy to use,
    > matainence, where as dynamic controls are flexibile but should manually
    > maintain the view state persitence, child controls, etc.
    >
    > If designed for specific functionality, dynamic controls can be
    > designed to provide faster access and/or with less memory footprint.
    >
    > This can be a topic of contreversy but I prefer to distingush this way.
    >
    > Hth,
    > Aru
    >
     
    Greg Young [MVP], Apr 26, 2006
    #7
  8. Varangian

    Varangian Guest

    oh a really big thanks for you all ... I was unsure of the difference
    ... I had to ask it here :) thanks again. I'll go for dynamic controls
     
    Varangian, Apr 27, 2006
    #8
    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. Chip
    Replies:
    1
    Views:
    391
  2. Mike

    Refreash DesignTime control.

    Mike, Jan 11, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    422
  3. General Chaud Caliente

    Segregating designtime from runtime

    General Chaud Caliente, Oct 17, 2003, in forum: ASP .Net Building Controls
    Replies:
    8
    Views:
    358
    Victor Garcia Aprea [MVP]
    Oct 24, 2003
  4. Alessandro Zifiglio

    Deleting controls at designtime in web Custom templated control

    Alessandro Zifiglio, Dec 13, 2003, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    152
    Alessandro Zifiglio
    Dec 13, 2003
  5. Replies:
    4
    Views:
    381
Loading...

Share This Page