Capture an Event in a composite control From control on a page

  • Thread starter Thread starter gdick
  • Start date Start date
G

gdick

In the most simple terms assume we have a Composite WebServer control

This Composite Control (CC) is just a "label"

private Label _lblCommissionType;

protected override void CreateChildControls()
{
Controls.Clear();

this._lblCommissionType = new Label();
this._lblCommissionType.Text ="Premium: ";
this.Controls.Add(_lblCommissionType);
}

protected override void Render(HtmlTextWriter writer)
{
EnsureChildControls();
_lblCommissionType.RenderControl(writer);
}


I want to add an Event Handler to this CC which captures the event of a
change in standard DropDownList drawn beside it on the page. i.e.
DropDownList1

When the Event is captured I want to change the text of the (CC) label

Please Help -- just ask for more details if required

C#
VS.NET 2003
..NET v1.1
 
There are some rather exotic ways of handling this. Here's the simplest
one....without getting all into TypeConverters and stuff:

Create a property called "DropdownName" that is a string.
When that property is set, Do a FindControl on the page for the Dropdown.
Register an Event Handler for the Dropdown control that changes the label's
text.
 
Back
Top