Creating and Using Composite Controls
This example showsyou how to write a control that composes itself from other server controls. The capability to do this is especially useful if you already have controls with functionality that you need and you just want to create a super-class that does much more. Listing 13.10 shows the control’s source code, and Listing 13.11 shows the .aspx file that uses it.
Listing 13.10. The Control’s Code Composed from Other Server Controls
namespace MyContro { [ShowInToolbox(true), ToolboxData(“<{0}:Composition1 runat=server></{0}:Composition1>”)] public class Composition1 : System.Web.UI.WebControls.WebControl, INamingContainer { public int Value { get { return Int32.Parse(((TextBox)Controls[1]).Text); } set { ... |
Get Special Edition Using® Microsoft® ASP.NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.