Like HTML server controls, web server controls are also processed server-side by the ASP.NET engine so these controls require a runat=“server” attribute to work properly. Unlike HTML Server controls, Web server controls do not necessarily map to specific HTML elements. In some cases, a Web server control may result in multiple HTML elements. For example, a TextBox control might render as an input tag or a textarea tag, depending on its properties.

Web Server Control Syntax

The syntax for creating a Web server control is as follows: ASP.NET provides these Web server controls to help you with rapid development. Unlike traditional HTML elements, server controls allow you to access different properties using server-side scripting. When using Web server controls, you need to ensure that you include the runat=“server” attribute. This will allow you to access the control’s properties within your code blocks, for example during a page load, or click event.

Web Server Controls

Web server controls include traditional form controls such as buttons and text boxes as well as other controls such as tables. They also include controls that provide commonly used form functionality such as displaying data in a grid, displaying menus, and so on. Here is a listing of some of the common Web Server Controls included in ASP.NET.

Starndard Web Server Controls

Data Server Controls

Validation Server Controls

Login Server Controls

Web Parts Server Controls

Example

In the following example, the markup is located in the .aspx file, and the VB or C# code is either in a script block within the .aspx page or in the code-behind page. The .aspx file contains a Hyperlink Standard Web Server Control.

ASPX

VB

C#

Another great resource to access is the MSDN Library found on Microsoft’s website.

ASP NET Web Server Controls - 12