Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net Control vs HTML Control Performance

I have heard that we should avoid Default ASP.Net Controls, because they are heavy regarding Viewstate and etc...

So I was thinkink in using , , HTML tags whenever I want to only show information, and use the Eval function to insert server-side code in a href or src atribute.

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

So I was planning in using explicit cast inside simple html tags.

Is this the best solution regarding performance? Do you have any other sugestion/opinion?

like image 248
Marco Avatar asked Dec 06 '22 04:12

Marco


1 Answers

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

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

It gets a bit more complicated with the more complex controls. All the different grids, for example. Those can be bulky, but they are very quick to write. Some of us who are working on large, enterprise, high-performance apps might write our own HTML (from code) to create a grid.

Unless performance is a big factor in your web app, then, I would suggest that you start out judiciously using the ASP.Net controls, substituting HTML for simple elements. Then, as you become more familiar with both kinds of controls, your judgment about what to use when will become better informed.

like image 76
DOK Avatar answered Dec 09 '22 16:12

DOK