Q
Problem solve Get help with specific problems with your technologies, process and projects.

When to use server controls and HTML controls on a Web form

I'm confused about when to use server controls and HTML controls on my Web form. Can you explain?
HTML controls have a 1-1 mapping with the HTML tags. Their programming model is just like plain HTML, as well as its properties, which are exactly those documented in the W3C specification for HTML (https://www.w3.org/TR/html4).

In order to set values and modify these controls from .NET code (server-side), you need to right-click on them and select Run As Server Control, which introduces us to the server control concept. A server control is one that is run by ASP.NET, and available to .NET code in the code-behind or runat="server" script sections. Non-server controls (HTML) are not processed by ASP.NET. Rather, they are just design-time "views" of the underlying HTML source of the page itself.

Server controls can be either HTML Server Controls or Web Forms Controls (a.k.a. WebControls). The difference between the two is about functionality and design-time support. The latter have better designers, a more intuitive programming model, more OOP, can control their own rendering logic to better target the client platform, etc. So, if you need to access a control from .NET code, I'd say you should use WebControls. On the other hand, if you don't need to change a label text, a table configuration, etc., go for the the (non-server) HTML controls, which render faster and don't consume resources on the server for processing.

Dig Deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

TheServerSide.com

Close