Write custom Web Composite controls with managed C ++

Source: Internet
Author: User


Hosting C ++Write custom WebWidget combination
 
 
 
What is a custom Composite Control?
Custom Web Composite Control, as its name says: one or more server programs and HTML controls are integrated into a single control. A custom Composite Control is similar in functionality to a user control. The biggest difference is that it only exists in its own set of Programs (or shares it with other controls ), it can be placed in a toolbar and provides a WYSIWYG view of the controls it contains.
On the other hand, custom Web control combinations are more difficult to create than user control, because Visual Studio. NET designers do not provide any tools to create them visually. Therefore, the question is: why should I replace user controls with composite controls? When distributing controls to multiple Web programs or systems, it is much better to use custom Web Composite controls, and user controls are best used where reuse is not emphasized, for example, if you are only planning to use controls on your own website, user controls may be a better choice. Basically, you have to make a trade-off between the extra effort you have made to create it and the number of reusable times you have obtained. At the same time, because the custom composite control only exists in its own Assembly, only one copy is required on each computer, and the user control is placed in the Web assembly. Therefore, it must be stored on every Web site that uses it.
 
 
Create a custom WebWidget combination
The procedure for creating a custom Web Composite Control is essentially the same as creating a custom superclass Web control. In this example, It is SearchControl. The first thing to do is to design the appearance of the control, after that, it looks like 1.
 

Figure 1: widget exterior in the designer
 
SearchControl, as shown above, consists of three server controls (actually there are four, which will be discussed later): a tag control, a text box control, and a button. In addition, the tricky part of custom Web Composite controls is that they do not have a good drag-and-drop design tool to support the creation of controls, but need to be done in the old way-manually writing code. However, it is not completely correct. You do not need to manually write the server or HTML control code here. How can you create the appearance of SearchControl?
First, write the definitions of three server controls in the SearchControl class:
 
Label * label;
TextBox & n

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.