Chapter 6
Web Controls
Now that you re 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 ve seen three of them already: TextBox, Button, and Label. Now it s 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= server to a conventional HTML tag (as in <input type= text runat= server >), the .NET Framework responds by instantiating an HTML control. Web controls come from classes defined in System.Web.UI.WebControls. They re declared explicitly by prefixing class names with asp:, and, of course, including runat= server attributes (for example, <asp:TextBox RunAt= server >). 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 ve divided the Web controls in the .NET Framework class library (FCL) into the following categories:
Simple 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 ll be to build sophisticated Web forms that take advantage of the best features ASP.NET has to offer.