tags:

views:

817

answers:

5

How to make and use composite control in asp.net?

+2  A: 

Check this question : http://stackoverflow.com/questions/17532/asp-net-custom-controls-composites

Shoban
+1  A: 

A composite control is a control that's composed of some child controls (which are added by overriding CreateChildControls method). For a detailed article on them see MSDN: A Crash Course on ASP.NET Control Development: Building Composite Controls

Mehrdad Afshari
A: 

here are some tutorials:

codesource.com

Codeguru.com

MSDN

A google for "Creating a composite Control would have helped you"

TheVillageIdiot
A: 

"A composite control is one made up of other built-in controls, such as text boxes. You also can create a control from scratch if you don't want to use the built-in controls"

http://www.codeguru.com/csharp/.net/net_asp/webforms/article.php/c12725

caiokf
+4  A: 

A composite control is a custom Web control that contains other controls. This sounds like a user control, but the composite control doesn’t provide the designer screen and .ascx file that lets you drag and drop controls on it at design time. Instead, you inherit from the CompositeControl class and add constituent controls to the Controls collection of your class.
A composite control is rendered out as a tree of constituent controls, each having its own life cycle and, together, forming a brand-new API. Because each of the child controls knows how to handle its own ViewState and PostBack data, you don’t need to write extra code to deal with this. To create a composite control, create a class that inherits from the CompositeControl class and overrides the CreateChildControls method. The CreateChildControls method needs to contain the code to instantiate the child controls and set their properties. If you want to be able to assign styles to the composite control, you should create an instance of the Panel class to provide a container that can have attributes assigned to it, add it to the Controls collection of your composite control, and then add your controls to the Panel control. If you need to create many composite controls that have similar methods or properties, consider creating a base class for your composite controls that has the common code.

Muhammad Akhtar