Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In VB.NET which is more efficient creating controls runtime or creating them at design time? If I create at runtime will it affect the performance?
Posted
Comments
Richard C Bishop 24-Apr-13 12:09pm    
Each is used for different reasons. It really just depends on what you are trying to accomplish.

1 solution

There is no difference at all.

If you look with attention what a designed does, you will see that the controls are always added during runtime, even if you develop the page code using the designer. The designer makes no difference, it only assists you in writing code. Just do yourself a great favor: create some pages using the designer and look at the auto-generated code. It will help you to understand how to do things in code.

What I explained above is related to all UI libraries, including Windows application. ASP.NET applications are different: actually, all the life cycle of a page goes between HTTP request and HTTP response, so the whole page (or its part, in case of using Ajax) is generated on the server side before HTTP response is sent, and then the page is rendered on client side. But when a page is rendered, the response is already generated, so there is no difference how it was generated.

The only difference which you may experience when you generate control is if you do some complex calculations on the server side you would need to populate controls or assign some properties. But this is a general thing; the calculations can be of any degree of complexity and require any CPU time; I think everyone understands this aspect.

—SA
 
Share this answer
 
Comments
Akinmade Bond 25-Apr-13 5:47am    
On point.
Sergey Alexandrovich Kryukov 25-Apr-13 9:25am    
Thank you,
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900