DekGenius.com
[ Team LiB ] Previous Section Next Section

5.1 HTML Controls

The HTML controls have a one-to-one mapping with HTML tags. You can create HTML controls and change their appearance by modifying their properties. HTML controls have an object model that closely resembles the HTML syntax of the elements, as well as the Dynamic HTML (DHTML) object model.

The attributes of an HTML tag correspond to the properties of the HTML control. The HTML controls are declared by using the standard HTML tags with the attribute runat="server". For example:

<input type="text" id="txtName" runat="server">

The id attribute is very important for all server controls if you plan to access your control programmatically, since it defines the name by which the object will be referenced in code.

In ASP.NET, the following HTML tags are supported as HTML controls:

<a>
<img>
<form>
<table>
<tr>
<th>
<td>
<select>
<textarea>
<button>
All <input> tags

You can declare other HTML tags as server-side controls by using the runat="server" attribute/value pair. However, these controls are not supported; instead, unsupported HTML elements are handled by a generic super HTML server control called HtmlGenericControl. The HTML elements you might typically handle in this way include <div>, <span>, <body>, and <font>.

    [ Team LiB ] Previous Section Next Section