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 pro-grammatically 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 [html][/html] tag, the classes that may act as container classes, and finally the HtmlImage class. Several classes in the second category also employ the HTML

tag. HTML server controls must reside within a containing [html]

[/html] control with the runat=”server” attribute.

HtmlAnchor Control:

The HtmlAchor control ([html][/html]) 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.

HtmlTable Control:

The HtmlTablecontrol mimics the Html [html]

[/html] tag. We may define rows using [html][/html] tags. Table cells are defined using [html]

[/html] tags. This control is a container control, so we can embed other controls in its cells.