SharePoint 2010: Using Event Receivers, Example 4: Canceling and Redirecting
Event receivers in SharePoint Foundation 2010 enable your custom code to respond when specific actions occur on a SharePoint object. In this sample, a user operation is cancelled (on error or for other reasons) and the user is redirected to a custom error page.