Home > Articles > Programming > C#

  • Print
  • + Share This
From the author of

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:

  1. 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.

  2. Right-click the tool palette and select Installed .NET Components.

  3. 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.

  4. 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 properties—it doesn't matter which one, but that action will make the control appear properly, as shown in Figure 1.

  5. Figure 1Figure 1 The composite custom control added to a web form.

  6. 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.

  • + Share This
  • 🔖 Save To Your Account