Using Server Controls - Web Forms in C# Part 4

Posted by in C# category on for Beginner level | Points: 250 | Views : 6443 red flag
Rating: 5 out of 5  
 1 vote(s)

The article gives an overview of Server Controls in ASP.NET.


ASP.NET web server controls are a group of controls used to develop Web Forms.

The term refers to a group of controls derived from the System.Web.UI.WebControls.WebControl base class.

The ASP.NET web server controls have been developed specifically for ASP.NET and have many useful features that make the creation of richer web user interfaces much simpler. One of these features is ASP.NET web server control is ability to automatically detect the client browser and render the HTML elements based on this information. As a developer, you don't have to worry about customizing your form for different browsers.

The control's class properties enable you to change its appearance and behavior. Remember that not all browsers support all the properties, but ASP.NET will create suitable code for the target browser. Because of this consistent programming model, you also have easy access to event handlers to generate responses to particular events on your form. You can use those already built in the base classes or create your own.

Although ASP.NET web server controls make it much easier to create a rich user interface, you have less control over exactly how the page is finally rendered in the user's browser. ASP.NET web server controls are grouped into four basic types: 

  • Intrinsic 
  • Validation 
  • Rich 
  • Data Rendering
These categories are for convenience only, and there are no strict boundaries between them. Each control is a fully programmable object, which you can manipulate using its properties, methods, and events. When you're creating a Web Form, you can use any of these types together. You can also add HTML server controls to the page.

Intrinsic controls are the most basic type of control. They mimic the respective HTML elements that allow you to create the basic form elements such as buttons, checkboxes, and text boxes. 
Be careful not to confuse these intrinsic controls with HTML server controls. Although the final result may look the same on your form, these controls use different code. 

For example, compare these two blocks of code for an OK button. The intrinsic server control - button code is

<asp:Button id=Button1 Text="OK"
runat="server" />

The HTML server control - HTMLButton code is

<button id="Button1"

Intrinsic controls are described in the following table.

Here is a description of some Intrinsic Controls:

Button: General-purpose button, to which you can attach an OnClick event handler.

CheckBox: Single checkbox.

DropDownList: Drop-down list box, also known as a combo box, for selecting from a list of items.

Hyperlink: Displays a hyperlink.

Image: Displays an image file.

Label: For displaying text on a page.

ListBox: A scrollable list of items for single or multiple selection.

Panel: Used as a container to group other controls.

RadioButton: A single radio button.

Table: An HTML table.

TableCell: A cell within an HTML table.

TableRow: A row within an HTML table.

TextBox: A single or multiple-lined text box, also known as a text field.

Rich controls provide extended functionality. Typically, the result is a combination of intrinsic controls and may require numerous lines of HTML to render in the user's browser.

The advantage for the developer is that rich controls are just like any other ASP.NET control and are defined and programmed in the same way.

At present, only a small number of rich controls have been developed. In time, however, Microsoft and third-party providers will be developing additional rich controls.

Here are some examples of rich controls that have been developed so far:



The AdRotator control allows you to display banner advertisements on a Web Form. Each time the page is loaded or refreshed, the advertisement is randomly changed. 


The Calendar control provides a one-month calendar for viewing and selecting a date. 


The CheckBoxList control provides a group of checkboxes that allow multiple selections. 


The ImageButton control provides a clickable image that also supports access to the clicked coordinates for image-map functionality. 


The LinkButton control provides a button with the appearance of a hyperlink that performs the logic you specify in an event handler. 


The RadioButtonList control provides a group of radio buttons that are mutually exclusive. 

Data-rendering controls are a type of rich control. Their purpose is to simplify the work of displaying data, particularly from databases.

Before you can use the data-rendering controls to display data, you need to bind a datastore to the control using the DataSource property.

There are three data-rendering controls at present. 

DataGrid shows a multicolumn, data-bound grid using the default template, with each field in a separate column. You can modify the appearance of the default template and add additional functionality such as hyperlink and button columns using the control's properties.

The DataList control displays data in a repeating list using the default template. You can modify the appearance and add functionality using the control's properties. Optionally, you can allow editing of the displayed data.

The Repeater control displays data in a similar way to DataList. The main differences are that there's no default template, so you have to define your layout, and the list is read only.

Thanks and Have Fun!!!!!

Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: John Doe
Member Level: Bronze
Member Status: Member,MVP
Member Since: 1/22/2011 7:38:35 AM
Country: India

Login to vote for this post.

Comments or Responses

Posted by: Karthikanbarasan on: 2/15/2011 | Points: 25
good one!!!
Posted by: Naimishforu on: 2/15/2011 | Points: 25
Thanks Karthik :)

Login to post response

Comment using Facebook(Author doesn't get notification)