HighTechTalks DotNet Forums  

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

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss Capture an Event in a composite control From control on a page in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Capture an Event in a composite control From control on a page - 08-10-2006 , 09:03 AM






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


Reply With Quote
  #2  
Old   
Teemu Keiski
 
Posts: n/a

Default Re: Capture an Event in a composite control From control on a page - 08-13-2006 , 04:51 AM






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
http://blogs.aspadvice.com/joteke




<gdick (AT) kerrhenderson (DOT) com> wrote

Quote:
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




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.