Besides HTML serve controls, web server controls, and validation controls, you can also create your own controls by embedding Web Forms controls. These controls are called custom controls. You create custom controls when the available controls can't provide the functionality you need. For example, if you want to create a data grid control with check boxes, combo boxes, calendars, and date controls, you can create a custom control derived from the available controls and the then write the additional functionality.
Server Controls and the .NET Framework Library
The .NET Framework library provides the System.Web and its 15 supporting namespaces to define Web classes. These namespace reside in the System.web.dll assembly. Before you use any Web namespaces, though, you need to add a reference to the System.web.dll assembly and include the required namespace in the application. Some major namespace of the Web series are System.Web, System.Web.UI, System.Web.UI.HtmlControls, System.Web.UI.WebControl, and System.Web.Services.
The System.Web Namespace
The System.Web namespace contains browser-and server-related classes and interfaces. For example, the HTTPRequest and HTTPResponse classes provide functionality to make requests for HTTP to retrieve and post data on the server through a browser. The HttpApplication class defines the functionality of an ASP.NET application. This namespace also contains the HttpCookie and HttpCookieCollection classes for manipulating cookies. The HttpFileCollection class provides access to and organizes file uploaded by client. You can use the HttpWriter class to write to the server through HttpResponse.
The System.Web.UI Namespace
The System.Web.UI namespace contains classes and interfaces that enable you to develop Web-based GUI applications similar to Windows GUI applications. This namespace provide classes to create Web Forms pages and controls. The control is the mother of all Web control classes and provides methods and properties for HTML, web or user controls. The page class represents Web page requested by the server in an ASP.NET application. It also has classes for data binding with the data-bound controls such as DataGrid and DataList. You'll see these classes in the examples in this article. In addition to these classes, it also includes state management, templates, and validation-related classes.
The System.Web.UI.HtmlControls Namespace
This namespace contains HTML control classes, which I've discussed in the "HTML Server Controls" section of this article. Some of these namespace classes are HtmlButton, HtmlControl, HtmlForm, HtmlImage, HtmlInputText, HtmlTable, and so on.
The System.Web.UI.WebControls Namespace
This namespace contains classes related to server controls and their supporting classes, as discussed in the "Web Server Controls" section of this article. Some of the classes are AddRotator, Button, Calendar, CheckBox, DataGrid, DataList, DropDownList, Hyperlink, Image, Label, ListBox, ListControl, Panel, Table, TableRow, and TextBox. Besides control classes, it also contains control helper classes. For example, the DataGridItem, DataGridColumn, and TableRow, TableCell, TableCellCollection, TableHeaderCell, and TableItemsStyle are helper classes of the table control.
The System.Web.Services Namespace
A web Service is an application that sits and runs on the Web server. System.Web.Service and its three helper namespaces System.Web.Service.Description, System.Web.Services.Discovery, and System.Web.Service.Protocol – provides classes to build Web services.
Why are Web Forms Controls called server-side controls?
Microsoft .NET Framework consists powerful Web controls. By using these Web controls you write powerful Web GUI applications similar to desktop applications. You can either write code for these controls manually or by using VS.NET, which supports the drag-and-drop design-time feature. In other worlds, you can drag and drop Web Forms controls onto a Web form, set properties by right-clicking on a control, and even write handlers by double-clicking on the control as you'd do in windows GUI applications such as Visual Basic.
When a client (Web browser) makes a call for Web control such as a Button or a DataGrid, The runat ="Server" (Discussed later in more detail) tells the Web server that the controls will be executes on the server and they'll send HTML data to the client at run-time after execution. Because the execution of these control events, methods, and attributes happens on the server, these controls are server-side Web controls. The main functionality of these controls includes rendering data from the server to the client and event handling. (The controls fire events and handle those events.)
Adding server side controls to a Web Form
You have two ways to add server controls to a Web Form (also referred as a web page). You can either use the VS .NET IDE to add server Controls or you can add controls manually by typing code using the <asp:> syntax.
Adding server control using VS .NET
Adding server controls using VS.NET is pretty simple. As you have seen in the "Developing your first ASP .NET Web Application" section of this article, you create a new ASP.NET Application project, open the toolbox, drag and drop controls from the toolbox, set properties, and write event handlers for the control.
Adding Server Controls Using ASP .NET Syntax
The other method of adding server controls to an application is that you write the code manually. VS.NET writes the code in the background foe you when you drop a control from the toolbox to Web form.
To add server controls manually, you create a text file and save it with an .aspx extension .NET utilizes XML tags to write server controls. A tag should a low XML syntax. Every ASP.NET control starts with asp: and a control name. For example, the following line a text box control: