1

Could someone help and explain how I can attach an event handler on a custom content type or a particular list?

Currently, when I deploy my event handler as a feature and activate the feature, it is applied to all the lists.

Thanks,

Matrich

2 Answers 2

2

Use the Receivers element in the element manifest with ListTemplateId for lists or add the Receivers element as a sub element to the XmlDocument element in the Content Type (read more here)

0

adding event receiver to document library /list programatically. here i am mentioning for Document Library.

     SPDocumentLibrary docLib = web.Lists.TryGetList("Temp Resources") as SPDocumentLibrary;
        docLib.EnableVersioning = true;
        docLib.EnableMinorVersions = false;
        docLib.Update();
        if (docLib != null)
        {
            docLib.EventReceivers.Add(SPEventReceiverType.ItemUpdating, Assembly.GetExecutingAssembly().FullName, "Event Receiver Class Name");
            docLib.EventReceivers.Add(SPEventReceiverType.WorkflowCompleted, Assembly.GetExecutingAssembly().FullName, "Event Receiver Class Name");
        }

Your Answer

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