In most cases you want to create your own list definition with your own event receiver that sould only react on events of your custom list. SharePoint ships with alot of list definitions with unique list type numbers: 100: Generic list You can create event receivers that react on events of these list types. To create a custom list definition you should use the visual studio template "List Definition" shipped with the VSeWSS 1.1. If you create a custom list with base type "document library" its id will also be 101. It's just a copy of the template you selected. First line of schema.xml after creating the custom list definition project: XML: So what you should do ist change the Type value to a non-used number: XML: You also have to modify the ListDefinition.xml XML: and the ItemEvntReceiver.xml XML: Now your event receiver will be called only by MyDocumentLibrary lists and no longer by all document libraries.
101: Document library
104: Announcements list
and many more.
Id="cc1b7796-28cb-4eeb-9ca5-fdacfadddecc"
xmlns="http://schemas.microsoft.com/sharepoint/">
Name="BskhDocumentLibrary"
/>
Id="faca01fe-8478-4116-8b72-1e243bda6268"
xmlns="http://schemas.microsoft.com/sharepoint/">
ListTemplateOwner="cc1b7796-28cb-4eeb-9ca5-fdacfadddecc"
ListTemplateId="999">
Thursday, January 28, 2010
How to bind SharePoint event receivers to a custom list definition
<List xmlns:ows="Microsoft SharePoint"
Title="List Definition1"
Direction="$Resources:Direction;"
Url="MyDocumentLibrary"
BaseType="1"
Name="MyDocumentLibrary"
Id="cc1b7796-28cb-4eeb-9ca5-fdacfadddecc"
Type="101"
xmlns="http://schemas.microsoft.com/sharepoint/">
<List xmlns:ows="Microsoft SharePoint"
Title="List Definition1"
Direction="$Resources:Direction;"
Url="MyDocumentLibrary"
BaseType="1"
Name="MyDocumentLibrary"
Id="cc1b7796-28cb-4eeb-9ca5-fdacfadddecc"
Type="999"
xmlns="http://schemas.microsoft.com/sharepoint/">
<Elements
<ListTemplate
DisplayName="My Dokument Library"
Description="Custom document library with custom event receiver doing cool things."
BaseType="1"
Type="999"
OnQuickLaunch="TRUE"
SecurityBits="11"
Sequence="110"
Image="/_layouts/images/itdl.gif"
DocumentTemplate="101"
</Elements>
<Elements
<Receivers
<Receiver>
<Name>ItemDeleted</Name>
<Type>ItemDeleted</Type>
<SequenceNumber>1</SequenceNumber>
<Class>faca01fe-8478-4116-8b72-1e243bda6268</Class>
</Receiver>
<Receiver>
<Name>ItemAdded</Name>
<Type>ItemAdded</Type>
<SequenceNumber>1</SequenceNumber>
<Class>faca01fe-8478-4116-8b72-1e243bda6268</Class>
</Receiver>
<Receiver>
<Name>ItemUpdated</Name>
<Type>ItemUpdated</Type>
<SequenceNumber>1</SequenceNumber>
<Class>faca01fe-8478-4116-8b72-1e243bda6268</Class>
</Receiver>
</Receivers>
</Elements>
Posted by Rami Reddy Annapu Reddy at 4:10 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment