Ask a Question related to ASP.NET Building Controls, Design and Development.
-
gdick@kerrhenderson.com #1
Capture an Event in a composite control From control on a page
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
SelectedIndexChanged in a 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
gdick@kerrhenderson.com Guest
-
composite control does not fire event
Hi I have an aspx-page, where I load my custom-control (see below). The problem I have is that the event does not fire. I really cant figure out... -
Not Able to trigger event in Composite Control
i have a datagrid and toolbar and have integrated them in my composite control(inherited datagrid) toolbar items are shown as for e.g... -
Composite Control - Event not firing in child control
Hello: I am experiencing an issue where I have a composite control (TestOuter) composed of more composite (TestInner) controls. When I am... -
Possible to create a composite control that has a child control that is a validator that validates the composite control itself?
I am attempting to create a composite control which has a label, followed by an optional error message, followed by two text boxes. I have... -
Using Table control in a custom composite control. Control does not render properly in design time.
All, I have written a very simple custom composite control that includes a control of type System.Web.UI.WebControls.Table. The control... -
Teemu Keiski #2
Re: Capture an Event in a composite control From control on a page
Hi,
if DropDownList is not inside the composite control, it doesn't make sense
for it to wire for the DropDownList's SelectedIndexChanged, since that would
make it always dependant of DDL on page. Instead you would expose Text
property from this composite control. Then handle DropDownList's
selectedIndexChanged on page and set the Text there. Unless your composite
control tries to address the need to have them together, of course.
However, it might make more sense, if you have the DropDownList in this very
same composite control, when accessing it inside the control would be very
easy. Another way is to define some "AssociatedDropDownListID" property in
the composite control, to which ID of the DropDownList is given. Composite
control could run Page.FindControl etc with the ID to get reference to the
DropDownList and use it, that's another way.
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
[url]http://blogs.aspadvice.com/joteke[/url]
<gdick@kerrhenderson.com> wrote in message
news:1155214999.211468.214640@75g2000cwc.googlegro ups.com...> 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
> SelectedIndexChanged in a 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
>
Teemu Keiski Guest



Reply With Quote

