I have many custom document libraries. I would like to create and attach an event receiver for all these Library. With <Receivers ListTemplateId="101"> they don't work. Any help is appreciated

  • Can you post your whole elements.xml here , bcoz <Receivers ListTemplateId="101"> is the correct way.
    – Unnie
    Jun 2, 2014 at 15:40

1 Answer 1


You can programatically attach the event receivers to your document library as

list = web.TryGetList("ListName");

 if (list != null) {
    list.EventReceivers.Add(SPEventReceiverType.ItemAdding, Assembly.GetExecutingAssembly().FullName, "Namespace.ClassName");


Or you can create a content type and attach event receiver to that content type and after that add that content type to your document library.

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.