ASP. NET component design step by step (1)

Source: Internet
Author: User

2004.8.1

Learn how to create a project library and apply it in your own project

1,StartVs200x

2,Select New Solution

3,Select the default solution type andWebControl library.WebThe control library is not requiredWebThe website is basicallyDLLType Library

4,Enter the name of your type library, for exampleAspctllibAnd so on. This determinesNamespaceAnd other projects in the future use the Reference Library name of this library.

5,Automatically generated by the systemCodeAs follows:

UsingSystem;

UsingSystem. Web. UI;

UsingSystem. Web. UI. webcontrols;

UsingSystem. componentmodel;

 

NamespaceAspctllib

{

/// <Summary>

///Abstract description of webcustomcontrol1.

/// </Summary>

[Defaultproperty ("text "),

Toolboxdata ("<{0}: webcustomcontrol1 runat = server ></ {0}: webcustomcontrol1>")]

Public ClassWebcustomcontrol1: system. Web. UI. webcontrols. webcontrol

{

Private StringText;

[Bindable (True),

Category ("appearance "),

Defaultvalue ("")]

Public StringText

{

Get

{

ReturnText;

}

Set

{

TEXT =Value;

}

}

 

/// <Summary>

///This control is displayed to the specified output parameter.

/// </Summary>

/// <Param name = "output">HTML writer to write</Param>

Protected Override VoidRender (htmltextwriter output)

{

Output. Write (text );

}

}

}

 

6,Assemblyinfo. CSIntroduction

7,Compile this project to obtainAspctllib. dll

8,Other project references

 

How to reference self-builtWebControl library

1,Open/CreateAsp.netProject

2,ReferenceAspctllib. dll, Will appear in the referenceAspctllibDLLCopy files to the directory of the current project

3,Set your ownWebAdd controls to the control libraryToolbarTab: Right-click the tab, customize the toolbox, and select. NetFramework components, browse, findAspctllib. dllAdd, you can see the nameWebcustomcontrol1Components exist in the toolbox

4,Open your ownAps.net WebProject, selectWebForm, you can add your own controls to it. By default, this control displays:[Webcustomcontrol1 "webcustomcontrol1"].

5,Select this control in the form and open the property for editing. Basically, the default design control has only oneTextProperty is a custom property. Enter a specific text.

6,Compile and view the results.

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.