RaiseBubbleEvent()

D

Darryl S.

Hi,
I'm trying to create a composite control composed of a
listbox and a label. I would like to bubble the
SelectedIndexChanged event of the listbox upwards to its
parent and expose it as an event (I called it
SelectedChanged) of the composite control.

I have seen egs on MSDN on how to use OnbubbleEvent() to
achieve this:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpguide/html/cpconbubblingcommandevent.asp

but the example used a Button insted of a ListBox. It
seems that OnBubbleEvent does not fire at all for the
ListBox's events (but it fires for the button's events).
any ideas?

Thanks,
Darryl.
---------Code snippet-----

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Xml;

namespace UIControls
{
public class SelectionList :
System.Web.UI.WebControls.WebControl, INamingContainer
{

.....code...
private ListControl theList = new ListBox
();

public event EventHandler SelectionChanged;

protected override bool OnBubbleEvent
(object source, EventArgs e) {
OnSelectionChanged(e);
return false;
}

protected virtual void OnSelectionChanged
(EventArgs e) {
if (SelectionChanged != null){
SelectionChanged(this, e);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top