Note that there are some explanatory texts on larger screens.

plurals
  1. POSP2010 Attach Event Receiver to specific list programmatically - runs for all lists
    primarykey
    data
    text
    <p>I'm attaching a event receiver to a single list (Web scope). But the ER runs for all lists in the Web. This <a href="https://stackoverflow.com/questions/4014020/how-can-i-add-event-receiver-only-for-list-with-specyfic-template-id">question</a> says that the feature, the ER is deployed in, have to be Web scope. This is the case.</p> <p>The Feature is activated programmatically bound to an ER of a list in the TLS.</p> <pre><code>newProjectWeb.Features.Add(new Guid("57e21870-6285-4e0a-b9a0-067f774492ae")); </code></pre> <p>Please see my code below. Am I missing an Update or anything?</p> <p>Thanks for your help in advance.</p> <pre><code>public void AddEventReceiverToMemberList() { try { _clsLists.AddEventReceiverToList(Web, ProjectMemberList.LIST_INTERNAL_NAME, typeof(SCMUProjectMemberList), SPEventReceiverType.ItemAdded); _clsLists.AddEventReceiverToList(Web, ProjectMemberList.LIST_INTERNAL_NAME, typeof(SCMUProjectMemberList), SPEventReceiverType.ItemDeleting); _clsLists.AddEventReceiverToList(Web, ProjectMemberList.LIST_INTERNAL_NAME, typeof(SCMUProjectMemberList), SPEventReceiverType.ItemUpdated); Web.Update(); } catch (Exception) { throw; } } public void AddEventReceiverToList(SPWeb web, string listName, Type eventReceiverClass, SPEventReceiverType eventType) { SPList list = this.GetListByName(web, listName); string className = eventReceiverClass.FullName; string assemblyName = Assembly.GetAssembly(eventReceiverClass).FullName; list.EventReceivers.Add(eventType, assemblyName, className); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload