So far, you have created user controls, which are essentially reusable web page fragments.[*] You can also create your own compiled custom controls . As noted earlier, there are three ways to create custom controls :
Create a derived custom control by deriving from an existing control.
Create a composite control by grouping existing controls together into a new control.
Create a full custom control by deriving from
The custom controls most similar to user controls are the composite controls. The key difference is that composite controls are compiled into a DLL and used as you would any server control you find in the Toolbox.
To get started, you'll create a Web Control Library in which you'll place the various custom controls for this chapter. Open Visual Studio .NET and choose New Project. In the New Project Window, create a Web Control Library called
CustomControls, as shown in Figure 13-4.
After clicking OK, you'll notice that Visual Studio has created a complete custom control named WebCustomControl1
. Before examining this control, create a web application to test it. Right-click on the solution in the Solution explorer and choose Add → New Web Site. Set the name of your web site to
CustomControlTester. Your solution now includes two projects: a web site (with Default.aspx) and a Custom Controls library (with WebCustomControl1.vb).
Web Custom Control 1 is a full custom control, ...