Bubbling Events to Parent in ASP.NET Bubbling Events to Parent in ASP.NET asp.net asp.net

Bubbling Events to Parent in ASP.NET


Event Bubbling is built into asp.net

Check this out: http://www.4guysfromrolla.com/articles/051105-1.aspx

Basically, to raise the event that you want bubbled up:

RaiseBubbleEvent(this, args);

And then to catch it:

protected override bool OnBubbleEvent(object source, EventArgs e) {    bool handled = false;    if (e is TemplatedListCommandEventArgs) {        TemplatedListCommandEventArgs ce = (TemplatedListCommandEventArgs)e;        OnItemCommand(ce);        handled = true;    }    return handled;}

As the code implies, if this method returns false, the event will continue to bubble up the control hierarchy

The implementation of RaiseBubbleEvent is provided by Control and cannot be overridden. RaiseBubbleEvent sends the event data up the hierarchy to the control's parent. To handle or to raise the bubbled event, a control must override the OnBubbleEvent method.

From MSDN: http://msdn.microsoft.com/en-us/library/aa719644(v=vs.71).aspx