SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.



share|improve this question

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)

share|improve this answer

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;
        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");
share|improve this answer

Your Answer


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