Reputation: 1272
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?
Upvotes: 4
Views: 4084
Reputation: 2826
Regarding using ASP.Net controls vs Html controls, for static content we can go for Html controls. But if you are heavily using Eval to bind data with controls, then we should use ASP.Net controls.
Regarding comparison between Gridview and listview, my experience is that ListView is more lightweight as compared to Gridview. Gridview provides more functionality, but it also loads the page heavily.
Upvotes: 2
Reputation: 32851
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.
Upvotes: 9
Reputation: 30181
Just use the default ASP .Net controls and disable viewstate via the properties menu.
Don't worry about the cost until you actually experience a problem.
Upvotes: 2
Reputation: 29157
If you're worried about things like this, then you're probably better off using ASP.NET MVC (particularly in regards to ViewState). Does your app currently have performance issues, or are you just worried about performance (the curse of the premature optimizer)?
Upvotes: 3