ASP.net 3.5 control and Component Development Technology series-Developing server controls from scratch (top)

Source: Internet
Author: User

Content of this chapter

3.1 Select base class

3.2 Control Rendering Order

3.3 Render rendering controls in several ways

3.4 AddAttributesToRender Method

3.5 CreateChildControls Method

3.6 INamingContainer Interface

3.7 Implementing a composite control

3.8 Common development techniques

3.1 Select base class

Select the control to develop the base class to inherit before you develop a control. These base classes encapsulate the most basic functionality of the control, improve code reusability, and each base class provides different functionality, and many common base classes are listed in chapter 1th, and if you're not sure, take a look at Chapter 1th.

Here is a brief discussion of the general development of the base class selected by the base control.

Control

Control to develop a base class that all controls inherit directly or indirectly from the class. Provides common properties and methods for various types of controls, such as unique flag ID attributes, visibility visible, and so on.

This class has only the most basic properties of the control and has the most flexibility to extend.

WebControl

In addition to inheriting all of the control's attributes, WebControl adds features such as layout, accessibility, appearance, and so on, and also extends many attributes to behavior.

Both control and WebControl are used to develop simple controls (that is, individual or non-component controls). Generally when the control is selected, if the control to be developed for the appearance of layout and style control characteristics such as high requirements, you can choose to inherit WebControl more convenient; If you have to choose control to implement WebControl characteristics is also possible, but to increase their own required properties, such as layout attributes width and height, it will be more difficult to achieve.

It is typically used most in web-based systems and has a strong scalability flexibility.

CompositeControl

This class is a control base class that is already supported when ASP.net version 2.0. If you aggregate existing controls to create a composite control, you can inherit this class, which implements the INamingContainer interface by default, and has better support for design pattern performance. The method of creation is described in detail later. Typically used to make a single control of multiple control sets with certain functionality.

Inheriting existing controls

The control with certain functions, such as Label,button, even the GridView, is used as the base class of the new control, and on this basis, it expands or changes (implemented by the override overload method) to meet the business needs.

In general, the development of a web-based control, the more common method is to inherit from WebControl; This chapter focuses on the process of developing a control. Take the inheritance WebControl as an example to begin to explain.

As long as it is a Web control, whether it is a asp.net control or a third-party vendor control, it is standard HTML markup that is ultimately resolved to the client. It is also possible to say that the process of making a control is to organize HTML and output based on the control's properties (simple values or complex data source collections, etc.) that are set by the user. Control is simply to abstract some common functions into a common control, improve reusability, save development time, which is much better than developers on each page with pure HTML development.

Control development can be understood as the process of organizing HTML. Of course asp.net control development technology provides some rules for effectively organizing output of these HTML tags in a variety of ways, as well as some help classes and functional support for styles, resource file encapsulation, and so on, so let's take a look at how the HTML tags are organized.

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.