3

I have Event Receiver for document library. It is added in Elements.xml like this:

  <Receivers ListTemplateId="101">

I would like to use this ER for all my document libraries. Do I have to put <Receivers> element for each of those lists, or is there easier way?

2 Answers 2

3

The <Receivers ListTemplateId="101"> specifies that the following receivers are for all lists created using the ListTemplate with Type=101, which is all the once created as pure "Document Libraries", but not "Asset Libraries", "Form Libraries", ... Custom List Templates.

If you need to cover all these then you need to either:

  • specify the entire list of theses (new <Receivers> element with all the children.
  • write an event receiver for ListAdded which checks for the type of list and then adds the receivers in code if BaseType is "1" and in a FeatureReciever for your feature loop through and add them to all existing lists with BaseType="1"
0

You can use a feature to bind the event receiver to all lists\libraries with a particular template ID

Please check the section New Event Registration technique using the <Receivers/> tag on this post : http://extreme-sharepoint.com/2011/12/27/event-receivers-sharepoint-2010/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.