ASP.Net control versus HTML control performance

I heard that we should avoid ASP.Net controls by default because they are heavy relative to ViewState etc ...

So, I thought that I use HTML tags whenever I want to show only information, and use the Eval function to insert server-side code into the href or src attribute.

But I also heard that the Eval function is not the best performance solution because it uses reflection to evaluate the passed argument.

So, I planned to use explicit casting in simple html tags.

Is this the best performance solution? Do you have any other recommendations / opinions?

+3
source share
4 answers

Instead of avoiding ASP.Net controls, perhaps you could think of it this way: don't use more than you need.

If you can use the HTML tag, use it. One commonly used ASP.Net control is a shortcut. You only need to use the shortcut if you need to format it differently from formatting styles. If you just put the text in HTML, you don't have to worry about ViewState. Similarly, many people use ASP.Net HyperLink when all they really need is <a> .

This gets a little trickier with more sophisticated controls. For example, all the different grids. They can be bulky, but they are very fast to write. Some of us who work on large corporate and high-performance applications can write our own HTML code (from code) to create a grid.

If performance is not a big factor in your web application, I would advise you wisely to start using ASP.Net controls, replacing HTML with simple elements. Then, when you become more familiar with both types of controls, your opinion on what to use when it becomes better informed.

+8
source

If you are worried about such things, then you are probably better off using ASP.NET MVC (especially regarding ViewState). Does your application currently have performance issues, or are you just worried about performance (damnation of premature optimizer)?

+3
source

Just use standard ASP.Net controls and turn off the viewstate via the properties menu.

Do not worry about the cost until you have a problem.

+2
source

Regarding the use of ASP.Net controls and Html controls for static content, we can use Html controls. But if you use Eval heavily to bind data to controls, then we should use ASP.Net controls.

As for the comparison between the Gridview and the list, my experience is that the ListView is lighter than the Gridview. Gridview provides more functionality, but also loads the page heavily.

+2
source

Source: https://habr.com/ru/post/1488811/


All Articles