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– Unnie2014-06-02 15:40:49 +00:00Commented Jun 2, 2014 at 15:40
Add a comment
|
1 Answer
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");
list.Update();
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.