ASP.NET Server Controls Hierarchy
The following illustration shows the namespaces that contain ASP.NET server controls.
ASP.NET server controls derive directly or indirectly from System.Web.UI.Control. This base class belongs to the System.Web.UI namespace, which contains the elements common to all ASP.NET server controls. Three commonly used controls belong to System.Web.UI — Page, UserControl, and LiteralControl. While Page is important because every ASP.NET page is compiled to a Page control by the ASP.NET page framework, control developers generally do not instantiate Page or derive from Page. Control developers also generally do not work with UserControl. User controls are developed using the same programming model as ASP.NET pages and are saved as .ascx text files. Control developers use LiteralControl extensively, as it allows text to be encapsulated as a control.
The ASP.NET server controls that provide a user interface are organized into two namespaces — System.Web.UI.HtmlControls and System.Web.UI.WebControls. The HTML server controls map directly to HTML elements, while the Web server controls are richer and more abstract.
HTML Server Controls Hierarchy
The following illustration shows the hierarchy of ASP.NET server controls in the System.Web.UI.HtmlControls namespace. These controls are called HTML server controls.
HTML server controls derive directly or indirectly from the base class System.Web.UI.HtmlControls.HtmlControl and map directly to HTML elements. HTML server controls are especially useful for migrating ASP applications to ASP.NET applications.
Web Server Controls Hierarchy
The following illustration shows the hierarchy of controls in the System.Web.UI.WebControls namespace. Controls in this namespace are called Web server controls.
Most Web server controls derive directly or indirectly from the base class System.Web.UI.WebControls.WebControl. However, the four controls in the upper-right corner (Literal, PlaceHolder, Repeater, and Xml) derive from System.Web.UI.Control. The controls on the left map to HTML elements. The controls in the center are for validating form input. Also in the center are controls that provide rich functionality, such as the Calendar and the AdRotator controls. The controls that provide data-binding support are on the right.
You can develop a custom Web server control by extending an existing Web server control, by combining existing Web server controls, or by creating a control that derives from the base class System.Web.UI.WebControls.WebControl.
浙公网安备 33010602011771号