Now that you鈥檙e acquainted with the Web Forms programming model, the next step on the road to becoming an ASP.NET programmer is getting to know the various types of server controls that the Microsoft .NET Framework places at your disposal. You鈥檝e seen three of them already: TextBox, Button, and Label. Now it鈥檚 time to learn about the others.
Recall from Chapter 5 that ASP.NET supports two distinctly different types of server controls: HTML controls and Web controls. HTML controls are instances of classes defined in the System.Web.UI.HtmlControls namespace. When you add runat=鈥渟erver鈥?to a conventional HTML tag (as in <input type=鈥渢ext鈥?runat=鈥渟erver鈥?gt;), the .NET Framework responds by instantiating an HTML control. Web controls come from classes defined in System.Web.UI.WebControls. They鈥檙e declared explicitly by prefixing class names with asp:, and, of course, including runat=鈥渟erver鈥?attributes (for example, <asp:TextBox RunAt=鈥渟erver鈥?gt;). HTML controls exist primarily to ease the chore of migrating existing HTML forms to ASP.NET. Web controls are richer and more diverse in scope than HTML controls, so the focus of this chapter is Web controls.
To lend order to the otherwise dizzying array of Web controls defined in the WebControls namespace, I鈥檝e divided the Web controls in the .NET Framework class library (FCL) into the following categories:
鈥淪imple鈥?controls, so called because (in general) they wrap simple HTML control tags
Button controls, which create various types of buttons in Web forms
List controls, which display simple lists of items
Data-bound controls, which use data binding to display information obtained from databases and other data sources
Calendar controls, whose sole member, Calendar, adds interactive calendars to Web forms
Validation controls, which validate user input before and after forms are submitted to the server
The more you know about Web controls, the better equipped you鈥檒l be to build sophisticated Web forms that take advantage of the best features ASP.NET has to offer.