Mega Code Archive

 
Categories / ASP.Net Tutorial / Custom Controls
 

Exposing control properties in a composite control (C#)

using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; using System.Web.UI; using System.Web.UI.WebControls; namespace WebControlLibrary1 {     [DefaultProperty("Text")]     [ToolboxData("<{0}:WebCustomControl2 runat=server></{0}:WebCustomControl2>")]     public class WebCustomControl2 : CompositeControl     {         protected TextBox textbox = new TextBox();         public string Text         {             get             {                 EnsureChildControls();                 return textbox.Text;             }             set             {                 EnsureChildControls();                 textbox.Text = value;             }         }         protected override void CreateChildControls()         {             this.Controls.Add(textbox);         }     } }