- Introduction to ASP.NET Composite Custom Controls
- Creating the Author Bio Composite Control
- Adding Your Composite Control to a Web Form
- Adding Properties
- Adding Events
- Summary
Adding Your Composite Control to a Web Form
Now that you've created a basic composite custom control, you need to create the web form to which you'll add the control:
Run the ASP.NET web application project wizard. After the new project is created, open the main web form in the GUI designer, which also enables the controls view of the tool palette.
Right-click the tool palette and select Installed .NET Components.
Click the Select an Assembly button and locate the DLL for the AuthorBio control (it's in the bin\debug directory of the AuthorBio project). After you've clicked the OK buttons and are back in the designer, you'll find a General section on the tool palette where the AuthorBio control resides. Now, just as with any other control, you can drag-and-drop it onto the design surface.
When you add the control to the surface, it will be a small box that doesn't show the constituent controls. To get the control to appear properly, make sure that the control is selected; then go to the Object Inspector and change any of the control's propertiesit doesn't matter which one, but that action will make the control appear properly, as shown in Figure 1.
Each time you modify the control, remove it from the web form and the tool palette, recompile the control, and re-add it. To remove a control from the tool, right-click the tool palette, select Installed .NET Components, and uncheck the control.
Figure 1 The composite custom control added to a web form.