SHARE
TWEET

How can a descendant UserControl intercept events fired by its base class

a guest Feb 26th, 2012 20 Never
  1. public event EventHandler OkClick;
  2. protected virtual void OnOkClick(EventArgs e)
  3. {
  4.     if (OkClick != null) OkClick(this, e);
  5. }
  6.        
  7. OnOkClick(EventArgs.Empty);
  8.        
  9. protected override void OnOkClick(EventArgs e)
  10. {
  11.     // do some stuff before the event is fired
  12.     base.OnOkClick(e);
  13.     // do some stuff after the event is fired
  14. }
RAW Paste Data
Top