Tutorial 5 Quick Reference

How to create a custom control composed of other server-side controls that lives in its own assembly

  1. Derive a class from System.Web.UI.Control

  2. Override the CreateChildControls method

  3. Visual Studio includes a project type, Web Custom Control, that fits the bill

How to add controls to a custom composite control

  1. Instantiate the child control

  2. Add the child control to the composite control's Control collection

How to add a custom control to the toolbox

  1. Show the toolbox if it's not already showing by selecting View | Toolbox from the main menu

  2. Right mouse click anywhere in the toolbox

  3. Select Choose Items from the local menu

  4. Choose a control from the list


  5. Browse to the assembly containing the control

How to tell ASP.NET to make up unique IDs for the child controls within the composite control

  • Add INamingContainer to the control's inheritance list

How to raise events within a custom composite control

  • Expose the events using the event keyword

Create composite controls with designer support

  1. Within a Visual Studio Web Site project, select Web site | Add New Item… from the main menu

  2. Select the Web User Control template