Computers & ProgrammingASP.NETBackend Development

ASP.NET Web Server Controls

ASP.NET Web server controls are ASP.NET specific objects or tags understood by the ASP.NET engine running in IIS.

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:controlName id="controlId" runat="server" />

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

ControlDescription
AdRotator Web Server ControlProvides a convenient way to display advertisements on your ASP.NET Web pages
BulletedList Web Server ControlCreates an unordered or ordered list of items, which renders as an HTML ul or ol element
Button Web Server ControlsAllow users to send a command via button, linkbutton, or imagebutton
Calendar Web Server ControlDisplays a one-month calendar
CheckBox and CheckBoxList ControlsProvide a way for users to switch between true-false for single and group boxes
DropDownList Web Server ControlEnables users to select from a single-selection drop-down list box
FileUpload Web Server ControlEnables you to provide users with a way to send a file from their computer to the server
HiddenField Web Server ControlEnables you to keep information in an ASP.NET Web page without displaying it to users
HyperLink Web Server ControlProvides a means of creating and manipulating links on a Web page from server code
Image Web Server ControlEnable you to display images on a Web Forms page
ImageMap Web Server ControlEnables you to create an image that has individual regions that users can click
Label Web Server ControlProvides a way to display text programmatically;rendered as a span element
ListBox Web Server ControlAllows users to select one or more items from a predefined list
Literal Web Server ControlRenders static text into a Web page without adding any HTML element
Localize Web Server ControlEnables you to display localized text in a specific area
MultiView and View ControlsAct as containers for other controls and markup, and present alternate views of information
Panel Web Server ControlProvides a container within the page for other controls
PlaceHolder Web Server ControlEnables you to place an empty container control, then dynamically add child elements at run time
RadioButton & RadioButtonList ControlsAllow users to select one item or from a predefined list
Substitution Web Server ControlSpecifies a section on an output-cached Web page that is exempt from caching
Table, TableRow, & TableCell ControlsCreates a general-purpose table
TextBox Web Server ControlProvides a way for users to type information into an ASP.NET Web page
Wizard Web Server ControlEnables you to build ASP.NET Web pages that present users with multi-step procedures
XML Web Server ControlReads XML and writes it into an ASP.NET Web page at the location of the control

Data Server Controls

ControlDescription
GridView Web Server ControlDisplays data as a table. Provides sorting, paging, editing, or deleting records
DetailsView Web Server ControlRenders a single record at a time as a table. Allows for paging and editing records
FormView Web Server ControlRenders a single record at a time from a data source and provides paging of records
Repeater Web Server ControlRenders a read-only list from a set of records returned from a data source
DataList Web Server ControlRenders data as table and enables you to display data records in different layouts
SqlDataSource Web Server ControlEnables you to work with Microsoft SQL Server, OLE DB, ODBC, or Oracle databases
AccessDataSource Web Server ControlEnables you to work with a Microsoft Access database
ObjectDataSource Web Server ControlEnables you to work with a business object and create applications that rely on middle-tier objects
XmlDataSource Web Server ControlEnables you to work with an XML file
SiteMapDataSource Web Server ControlUsed with ASP.NET site navigation

Validation Server Controls

ValidatorDescription
RequiredFieldValidatorEnsures that the user does not skip an entry
CompareValidatorCompares a user’s entry against a constant value, against the value of another control, or for a specific data type
RangeValidatorChecks that a user’s entry is between specified lower and upper boundaries
RegularExpressionValidatorChecks that the entry matches a pattern defined by a regular expression
CustomValidatorChecks the user’s entry using validation logic that you write yourself
ControlDescription
Menu Web Server ControlEnables you to add functionality to your web pages that are often used to provide navigation
SiteMapPath Web Server ControlDisplays a navigation path, also known as a breadcrumb
Treeview Web Server ControlDisplays hierarchical data, such as a table of contents or file directory, in a tree structure

Login Server Controls

ControlDescription
Login ControlDisplays a user interface for user authentication
LoginView ControlAllows you to display different information to anonymous and logged-in users
LoginStatus ControlDisplays a login link for users who are not authenticated and a logout link for users who are authenticated
LoginName ControlDisplays a user’s login name if the user has logged in using ASP.NET membership
PasswordRecovery ControlAllows user passwords to be retrieved based on the e-mail address that was used when the account was created

Web Parts Server Controls

ControlDescription
AppearanceEditorPart ControlProvides an editor control that enables users to edit several UI properties on an associated WebPart control
BehaviorEditorPart ControlProvides an editor control that enables users to edit properties that affect the behavior of an associated WebPart
CatalogZone ControlServes as the primary control in the Web Parts control set for hosting CatalogPart controls
ConnectionsZone ControlProvides a UI that enables users to form connections between WebPart and other server controls
DeclarativeCatalogPart ControlEnables you to add a catalog of WebPart or other server controls to a Web page
EditorZone ControlServes as the primary control in the Web Parts control set for hosting EditorPart controls
ImportCatalogPart ControlImports a description file for a WebPart control
LayoutEditorPart ControlProvides an editor control that enables users to edit several layout-oriented UI properties
PageCatalogPart ControlProvides a catalog that keeps references to all WebPart controls that a user has closed
PropertyGridEditorPart ControlProvides an editor control that enables end users to edit custom properties on an associated WebPart
ProxyWebPartManager ControlProvides a way to declare static connections in a content page
WebPartZone ControlServes as the primary control in the Web Parts control set for hosting WebPart 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

<asp:HyperLink ID="HyperLink1" runat="server" />

VB

Sub Page_Load(sender As Object, e As EventArgs)
    HyperLink1.NavigateUrl = "https://www.itgeared.com"
End Sub

C#

void Page_Load(object sender, EventArgs e) 
{ 
   HyperLink1.NavigateUrl = "https://www.itgeared.com";
}
6Ljm2O3A

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

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top