HTML Server Controls in ASP.NET With Examples
HTML Server Controls in ASP.NET:
In ASP.NET, we may convert an HTML element to an HTML server control by adding an attribute runat=”server”. This notifies the ASP Engine to create an instance of the control during parsing. We need to specify an ID of the element so that we can manipulate it programmatically on the server side. These controls are particularly useful for migrating ASP applications to ASP.NET applications.
HTML server controls have been derived directly or indirectly from the base class.
Basically, the hierarchy divides the classes into three major categories: the classes that mimic the HTML
<input> tag, the classes that may act as container classes, and finally the HtmlImage class. Several classes in the second category also employ the HTML
<input> tag. HTML server controls must reside within a containing
<form> control with the runat=”server” attribute.
The HtmlAchor control (
<a>) is used to navigate from one page to another page. It basically works almost like the Html anchor tag, the only difference is that it works on the server.
The HtmlTablecontrol mimics the Html
<table> tag. We may define rows using
<tr> tags. Table cells are defined using
<td> tags. This control is a container control, so we can embed other controls in its cells.