SharePoint (MOSS) Event Handlers using Content Type Deployed as Features

In my post earlier, I wrote how to create event handlers which get associated with all the lists/document libraries of specific types. You can change the elements.xml file as follows to create and register event handlers against it. Later you can associate the content type with any document library for example, to associate the event handler only to that particular library.

Elements.xml file contents would look like this:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentType ID="0x010100B6507616196543198ED529CE8720311F" Name="MyContentType" Group="MyGroupForContentType" Description="Event handler enabled content type." Version="0">
<XmlDocuments>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events">
<spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events">
<Receiver>
<Name>ItemDeleting</Name>
<Type>ItemDeleting</Type>
<SequenceNumber>2500</SequenceNumber>
<Assembly>MyProject, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=456g1dh4314356c3</Assembly>
<Class>MyProject.MyEventHandlerClass</Class>
<Data>
</Data>
<Filter>
</Filter>
</Receiver>
</spe:Receivers>
</XmlDocument>
</XmlDocuments>
</ContentType>
</Elements>

Comments

Popular posts from this blog

Unable to delete Shared Services Provider in SharePoint (MOSS)

The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

Cannot add a SimpleContent column to a table containing element columns or nested relations