By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,991 Members | 1,737 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,991 IT Pros & Developers. It's quick & easy.

Creating controls at runtime or designtime

P: n/a
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 :)

Apr 26 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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

Apr 26 '06 #2

P: n/a
thanks for the reply :)

I wish more would comment on this

Apr 26 '06 #3

P: n/a
Test and see for yourself??

"Varangian" <of****@gmail.com> wrote in message
news:11*********************@v46g2000cwv.googlegro ups.com...
thanks for the reply :)

I wish more would comment on this

Apr 26 '06 #4

P: n/a
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" <of****@gmail.com> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.com...
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 :)

Apr 26 '06 #5

P: n/a
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" <of****@gmail.com> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.com...
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 :)

Apr 26 '06 #6

P: n/a
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" <ar*********@gmail.com> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.com...
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

Apr 26 '06 #7

P: n/a
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

Apr 27 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.