Friday, 7 May 2010

Aborting a Sitecore event

So you've managed to intercept a Sitecore event, but you now need to stop all other events from occurring. I've had to do this when creating an alias to make sure it doesn't effect any other item. So we check all the possible clashes in the item:creating event, if one is found we won't to stop all further processing.

To stop the further processing all you need to do is call the following:

SitecoreEventArgs.Cancel(args);

You may also want to pass a message to the user, so just add a call to SheerResponse.

SheerResponse.ShowError(shortDescription, longDescription);

No comments: