Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

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"
share|improve this answer
add comment

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/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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