Article 1: ASP. NET control development _ Section 1: control classes and their inheritance relationships, and asp.net

Source: Internet
Author: User

Article 1: ASP. NET control development _ Section 1: control classes and their inheritance relationships, and asp.net

1) System. Web. UI. Control (Control))

ControlClass is the base class of all ASP. NET Server controls, including custom controls, user controls, and pages .. Defines the properties, methods, and events shared by all ASP. NET Server controls.

Namespace:System. Web. UI
Assembly:System. Web (in system. web. dll)

2) System. Web. UI. WebControls. WebControl (WebControl)

WebControlClass is the base class of all controls in the System. Web. UI. WebControls namespace .. It is derived from the Control class and defines the public attributes, methods, and events shared by all Web server controls. (MSDN ).

However, the decompilation of Literal indicates that the Literal Control is directly derived from the Control class in the System. Web. UI. WebControls namespace. (See)

Namespace:System. Web. UI. WebControls
Assembly:System. Web (in system. web. dll)

3) System. Web. UI. WebControls.CompositeControl(Hereinafter referred toCompositeControl)

CompositeControlClass is an abstract class derived from WebControls to implement the basic functions required by Web controls that contain child controls.

Namespace:System. Web. UI. WebControls
Assembly:System. Web (in system. web. dll)

  • Control,WebControl,Inheritance relationship between CompositeControl
    • System. Object
    • System. Web. UI. Control
    • System. Web. UI. WebControls. WebControl
    • System. Web. UI. WebControls. CompositeControl
When developing controls, select the base class:

1) First, ASP. all standard controls in. NET can be used as the base class. Therefore, if the control to be implemented is only a small modification or supplement to a standard control, the standard control can be used as a base class.

2) When the appropriate prototype cannot be found for the Control to be implemented in the standard Control, three base classes: Control, WebControl, and CompositeControl should be considered. (For details about how to select a base class, see)


All user-defined controls in aspnet must inherit from what ()?

Does not have a specific inheritance class ~
However, the base class is eventually a Control class.

Generally, custom controls inherit one of the following three classes:
Control: The base class of all controls. Applicable to custom controls that do not require any style attributes, such as Panel Literal Repeater controls;
WebControl: Provides style attributes based on Control, such as BorderColor.
CompositeControl: used to create custom controls that combine multiple existing controls.
Override CreateChildControls () to create a control tree.
Override the RenderContents () method to control the interface layout of the control (the default method is to call the RenderControl () method of all Controls in the Controls set)

In addition, custom data binding controls also have a series of inheritance base classes:
BaseDataBoundControl: provides a basic data binding mechanism. For example, the DataSource attribute is added. It is applicable to creating a simple custom data binding control bound to a single data item;
BaseDataList
HierarchicaDataBoundControl: added support for hierarchical data sources
DataBoundControl: added the performanceid attribute to support data source controls, such as SqlDataSource;
ListControl: a custom data binding control that displays a set of data items on a fixed user interface. Example: CheckBoxList;
CompositeDataBoundControl

The above is a general inheritance base class. Of course, you can also inherit from specific controls, such as HyperLink, as needed.

Above ~

All Custom User Controls in ASPNET must inherit from?

Of course, Control UserContro is the inheritance of user controls.
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.