It takes an object reference and an EventArgs reference
but returns a bool. The bool return value indicates whether or not the control has processed the
bubble event. A value of false indicates that the bubble event should continue bubbling up the
control hierarchy; a value of true indicates a desire to stop the event in its tracks, because it has
been handled. If a control does not implement OnBubbleEvent, the default implementation
passes the event on up to parent controls.
The Pager control implements its OnBubbleEvent as shown in Listing 5-15.
Listing 5-15. The Pager Implementation of OnBubbleEvent
protected override bool OnBubbleEvent(object source, EventArgs e)
{
bool result = false;
CommandEventArgs ce = e as CommandEventArgs;
if (ce != null)
{
if (ce.CommandName.Equals("Page"))
{
PageDirection direction;
if (ce.CommandArgument.Equals("Right"))
direction = PageDirection.Right;
CHAPTER 5 ?– SERVER CONTROL EVEN TS 229
else
direction = PageDirection.Left;
PageCommandEventArgs pce =
new PageCommandEventArgs(direction);
OnPageCommand(pce);
result = true;
}
}
return result;
}
The result variable holds the return value of OnBubbleEvent for the Pager control. It is set
to false, assuming failure until success.
Pages:
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332