I've recently discovered this technique in my ASP.NET code base that I maintain. What does it do and how would I use it? And Maybe more importantly, would this work at all given ASP.NET is using simulated-page-life-cycle-events?
public event EventHandler CancelEvent
{
add { cancelButton.Click += value; }
remove { cancelButton.Click -= value; }
}
Resharper says the event is currently unused and I've never seen this technique before. Usually I wire up my events on OnInit.. eg.
cancelButton.Click += HandleClick;