What is HTML Server Control?
HTML server controls are the HTML tags that are understood by the server. By default HTML elements in ASP.NET files are, treated as text to make these elements programmable, we will add runat="server" attribute to the HTML element. This attribute is treated as a server control. The HTML server controls are basically the standard HTML controls enhanced to enable server-side processing.
ASP.NET requires that all HTML elements must be properly closed and properly nested. And all HTML Server controls can be accessed through the Request object.
The server does not process HTML controls such as header tags, anchor tags, and input elements; instead, they are delivered to the browser for display. For example, see the HTML input control below:
This input control could be converted to an HTML server control by adding the runat and id attribute:
List of HTML Server Controls
HTML Server Control |
HTML Tag |
HTMLAnchor |
<a> element |
HTMLButton |
<button> element |
HTMLForm |
<form> element |
HtmlInputFile |
<input type="file"> element |
HtmlSelect |
<select> element |
HTMLForm |
<form> element |
HTMLImage |
<image> element |
HTMLInputCheckBox |
<input type="checkbox"> element |
HtmlInputImage |
<input type="image"> element |
HtmlInputRadioButton |
<input type="radio"> element |
HtmlInputText |
<input type="text"> element |
HtmlTable |
<table> element |
HtmlTableRow |
<tr> element |
HtmlTableCell |
<td> element |
Advantages
i) The HTML server controls follow the HTML-centric object model which is similar to HTML.
ii) When the ASP.NET application is compiled, the HTML server controls with the runat="server" attribute are compiled into the assembly.
iii) Most controls include an OnServerEvent for the most commonly used event for the control.
iv) The HTML server controls can interact with the Client side scripting. And the migration of the code can be made easy by adding runat="server" attribute.
v) The HTML tag abstraction is related to the HTML server control.
vi) When the ASP.NET page is reposted, the HTML server controls keep their values.