Search code examples
c#asp.netcomposite-controls

Expose OnSelectedIndexChanged event in CompositeControl


If I have a DropDownList control that makes up part of a CompositeControl how can I expose the SelectedIndexChanged event to the consuming aspx page?

Thanks


Solution

  • There is a much simpler way that is a direct pass through.

    Try this:

        public event EventHandler SelectedIndexChanged
        {
            add { this.TargetControl.SelectedIndexChanged += value; }
            remove { this.TargetControl.SelectedIndexChanged -= value; }
        }
    

    [Edit] Unless of course you need to inject custom logic.