Controls are small building blocks of the graphical user interface, which include text boxes, buttons, check boxes, list boxes, labels, and numerous other tools. Using these tools, the users can enter data, make selections and indicate their preferences.
Controls are also used for structural jobs, like validation, data access, security, creating master pages, and data manipulation.
ASP.NET uses five types of web controls, which are:
- HTML controls
- HTML Server controls
- ASP.NET Server controls
- ASP.NET Ajax Server controls
- User controls and custom controls
ASP.NET server controls are the primary controls used in ASP.NET. These controls can be grouped into the following categories:
- Validation controls - These are used to validate user input and they work by running client-side script.
- Data source controls - These controls provides data binding to different data sources.
- Data view controls - These are various lists and tables, which can bind to data from data sources for displaying.
- Personalization controls - These are used for personalization of a page according to the user preferences, based on user information.
- Login and security controls - These controls provide user authentication.
- Master pages - These controls provide consistent layout and interface throughout the application.
- Navigation controls - These controls help in navigation. For example, menus, tree view etc.
- Rich controls - These controls implement special features. For example, AdRotator, FileUpload, and Calendar control.
The syntax for using server controls is:
<asp:controlType ID ="ControlID" runat="server" Property1=value1 [Property2=value2] />
In addition, visual studio has the following features, to help produce in error-free coding:
- Dragging and dropping of controls in design view
- IntelliSense feature that displays and auto-completes the properties
- The properties window to set the property values directly