ASP.NET Webform: inline code (<%= %> ) vs Server Control Performance?
-
Let's forget about state management, maintenance perspective, etc ... and focus on render performance only Which of render method has better performance ? <%= ... %> or Server Control (orĀ Html Server Control/ Custom Control/ UserControl) ? e.g 1: <a href='<%=ResolvedUrl("~/Page1.aspx")'>Page1</a> vs <asp:HyperLink ID="lnk1" runat="server" NavigateUrl="~/Page1.aspx" /> e.g 2: using <% %> with foreach to render a DataTable vs using DataGrid In my opinion, <% %> will win not only in these 2 examples but also in most cases. As in http://ASP.NET MVC, we use inline code in Views to render HTML. What's your opinion ?
-
Answer:
I always recommend that people stop relying on http://ASP.NET Web Forms controls for simple non-form HTML elements like links, labels, text, etc. The performance is better and you'll have an easier time to convert to http://ASP.NET MVC in the future.
Karthik Hariharan at Quora Visit the source
Other answers
This is actually an apples-to-oranges comparison. Render-time-wise, Server Controls will always render slower than pure HTML with inline code, because of all the extra work involved in creating the Server Control, such as creating and maintaining the viewstate, executing the events chain, using filters etc. However, Server Controls has the advantage of functionality available in the server side, as opposed to pure HTML elements. In general, if you don't need the server side functionality of the Server Controls, don't use them. But if, however, you'll want to make your link visible or non-visible in your server side code, or would like the built-in sort functionality of the GridView - then use them.
Memi Lavi
Related Q & A:
- How can I allow user to create posts in website using ASP.NET?Best solution by Programmers
- How to Undo previous action in asp.net?Best solution by forums.asp.net
- How to Search using jQuery ASP.Net?Best solution by Stack Overflow
- How to save high resolution image canvas to server using asp.net?Best solution by Stack Overflow
- When purchasing a new tv, does 60 HZ vs 120 Hz REALLY matter?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.