The Architecture of ASP.NET Web Controls                 
                      
ASP.NET developers can utilize any of three types of Web controls. They are:
      •        Standard HTML Controls
      •        HTML Server Controls
      •        Web Controls (Web Server Controls)

HTML Controls are the same controls that were introduced with the HTML standardization. ASP.NET
developers cannot interact with HTML Controls with server-side cold using C# or VB. However, they can
still access them from client-side JavaScript. HTML controls can be dragged and dropped to the Visual Studio
Design pane from the HTML section of the Toolbox.
































HTML controls can also be written directly into the markup. Note that each HTML control must have an
“ID” attribute with a unique value, as required by the XHTML standard. Visual Studio offers full IntelliSense
for all control elements (tags) and attributes.

HTML Server Controls are identical to HTML Controls in every way except:
      •        They must have the attribute
runat=”server”.
      •        They are accessible by ASP.NET Web server code.
      •        HTML Server Controls are part of the .NET framework.

HTML Server Controls help developers migrate HTML files with standard HTML controls to ASPX files
with HTML Server Controls. HTML Server Controls were introduced to allow ASP.NET developers to
interact with predefined standard HTML controls with server-side code. All of the HTML Server Controls
are defined in the
System.Web.UI.HtmlControls namespace.nThe popular HMTL controls are represented
here with HTML Server Control equivalents. If a rarely-used HTML control has the
run=”server” attribute
added to it, ASP.NET will treat it as an
HTMLGenericControl control.






















HTML Server Controls are not available in the Visual Studio Toolbox! Instead, a standard HTML control
must be added to the Design pane and the
runat=”server” attribute must be added to its markup.

Interestingly, in Visual Studio 2002/2003/2005, HTML controls could easily be converted to HTML Server
Controls by right-clicking each of them and choosing “Run As Server Control”.






























However, support for this capability ended with the release of Visual Studio 2008. Microsoft considered it a
lesser-used functionality and it was decidedly dropped. In VS 2008, the only way to convert an HMTL
control to an HTML Server Control is by manually adding the necessary
runat=”server” attribute.

Web Controls are an abstraction of the standard HTML controls. All Web Controls are rendered out to the
client’s Web browser as standard HTML controls. Sometimes, a single Web Server Control emits several
HTML controls! For example, the Calendar Web Control is actually rendered as an HTML table (<table>)
with a series of table rows (<tr>), table data cells (<td>) and anchors (<a>).

All Web Controls are defined in the System.Web.UI.WebControls namespace:



























These controls use properties slightly different than their HTML counterparts. For example, the Button Web
Control exposes a
Text property while the HTML Button control uses the value attribute. This model
makes Web development an easier transition for novice ASP.NET developers already experienced with
creating Windows Form applications. 

These controls are located in the Standard in the section of the Visual Studio Toolbox.


















Some of the Web Controls found in the Visual Studio Toolbox are much richer than the standard HTML
controls. For example, there are the Ad Rotator, the Calendar, the GridView and many more.

ASP.NET Web controls use an “ASP:” prefix in their markup. The <
asp:ControlName… prefix and the
runat attribute will be stripped out of the control as it is rendered to a standard HTML input button before
sent to the Web browser. The properties will also be converted to standard input button attributes. For
example,
Text will become value.

Here are some things to remember with HTML Server/Web Controls:
      •        All controls must have a unique ID, as dictated by the XHTML standards.
      •        They must have the
runat=”server” attribute.
      •        The control attributes can be modified either in the Properties window or directly in the HTML
               markup.
Architecture of ASP.NET Controls
Table of Contents
Copyright (c) 2008.  Intertech, Inc. All Rights Reserved.  This information is to be used exclusively as an
online learning aid.  Any attempts to copy, reproduce, or use for training is strictly prohibited.
Courseware
Training Resources
Tutorials
Services