Exposing control properties in a composite control (C#) : Extends CompositeControl « Custom Controls « ASP.NET Tutorial






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);
        }
    }
}








14.21.Extends CompositeControl
14.21.1.Creating a composite control (C#)
14.21.2.Creating a composite control (VB)
14.21.3.Exposing control properties in a composite control (C#)
14.21.4.Exposing control properties in a composite control (VB)
14.21.5.TitledText Box