Specifies a server-side code routine that is called when registered events occur within the SharePoint environment. Custom event handlers can be attached to and have a scope of Web application, site collection, Web site, list, or document library.
Real World Example
A developer of an extranet management system determines that whenever any site collection is deleted, a call should be made to a database to update the corresponding information about the site deletion event. To implement this, the developer creates an event handler and includes it as a Feature that is then associated with all existing and new site collections.
Microsoft Office SharePoint Server 2007 and Windows SharePoint Services 3.0 event handlers can be installed through feature event receivers by having the feature event receiver add a reference to the event callback routine in the applicable event handler collection.
The following is an example of a list event receiver registered as part of the elements of a Feature definition.
<Receivers ListTemplateId="104"> <Receiver> <Name>SimpleEvent</Name> <Type>2</Type> <SequenceNumber>10000</SequenceNumber> <Assembly>SimpleEventHandler, Version=220.127.116.11, Culture=neutral, PublicKeyToken=10b23036c9b36d6d</Assembly> <Class>MS.Samples.SimpleEventHandler</Class> <Data></Data> <Filter></Filter> </Receiver> </Receivers>
In earlier versions of SharePoint Products and Technologies, event handlers were configured only for document libraries and had to be allowed at the Web application level first. This configuration method is still possible in Office SharePoint Server 2007 and Windows SharePoint Services 3.0, but these types of event handlers are called backward-compatible event handlers.
Event handlers introduce similar risks to environment performance as the backward-compatible event handler model. This can be especially obvious if the event handler calls a moderately long-running operation that is triggered by an event such as a document update, when used in conjunction with a heavily updated document library.