2004.8.1
Learn to create an engineering library, apply in our project
1, start VS200X
2, choose new solution
3. Select the default scheme type and select the web control library. The web control library does not require a Web site, basically a DLL type library
4. Enter the name of your own type library, such as Aspctllib. This decided NameSpace and other reference library names using this library.
5, the code automatically generated is as follows:
Using system;
Using system.Web.ui;
Using system.Web.ui.webcontrols;
Using system.componentmodel;
Namespace aspctllib
{
///
/// WebCustomControl1 summary description.
/// summary>
[DefaultProperty ("Text"),
ToolboxData ("<{0}: WebcustomControl1 Runat = Server> {0}: WebcustomControl1>")]
Public class WebcustomControl1: System.Web.ui.WebControls.WebControl
{
PRIVATE STRING TEXT;
[Bindable (TRUE),
Category ("APPEARANCE"),
DEFAULTVALUE ("")]
Public String Text
{
get
{
Return TEXT;
}
set
{
TEXT = VALUE;
}
}
///
/// Rendeze this control to the specified output parameter.
/// summary>
/// HTML writer to be written param>
Protected Override Void Render (HTMLTextWriter Output)
{
Output.write (text);
}
}
}
6, introduction of askMBLYINFO.CS
7, compile this project to get aspctllib.dll
8, other items reference
How to refer our own web control library
1, open / create an ASP.NET project
2, reference aspctllib.dll, will appear aspctllib in the reference, and copy the previous DLL file to the current project
3. Add your own web control library to TOOLBAR tab: Right-click tab, customize toolbox, select .NET Framework component, browse, find aspctllib.dll to join, you can see the component called WebcustomControl1 Toolbox
4. Open your own APS.NET Web project, select a web form, you can join your control. This control will appear when the default design: [WebcustomControl1 "WebCustomControl1"].
5, select this control in the form, open the properties to edit, basically the default design control only one text property is a custom property, enter a specific text.
6, compile, browse the effect.