This book focuses on using ASP.NET server controls . However, understanding and using HTML and HTML server controls can be useful in real-life applications.
Normal HTML controls such as
<input> are not processed by the server but are sent directly to the browser for display. Standard HTML controls can be exposed to the server and made available for server-side processing by turning them into HTML server controls.
To convert an HTML control to an HTML server control, simply add the attribute
runat="server". In addition, you will probably want to add an
id attribute, so the control contents can be accessed and controlled programmatically. For example, start with a simple input control:
<input type="text" size="40">
You can convert it to an HTML server control by adding the
runat attributes, as follows:
<input type="text" id="BookTitle" size="40" runat="server">
There are two main reasons for using HTML server controls rather than ASP.NET server controls:
To convert an HTML file to run under ASP.NET, all you need to do is change the extension of the file to .aspx. However, the HTML controls will run client side, not server side. To take advantage of server-side processing, including automatic maintenance of state (see Chapter 6), you must add the
Server-side controls consume server resources. For static tables commonly used to lay out the page, ...