Question

I have an ItemAdding event handler created and targeted to a Custom List. The event receiver seems to be firing on all custom list on the site. I wonder if I should target it to a specific custom list. Is this possible? or should I just leave it like it is now? If it's possible, how?

Was it helpful?

Solution

Navigate to corresponding Elements.xml, and you will notice Receivers element with ListTemplateId attribute, like this:

<Receivers ListTemplateId="100">
   ...
</Receivers>

What you need is to use ListUrl attribute instead, and point it to the specific list using provided url.

There is a how-to on this on MSDN:

Basic example:

<Receivers ListUrl="Lists/Test">
   ...
</Receivers>

Full schema of Receivers element could be found in Receivers Element MSDN reference article.

Also, the binding could be performed programmatically (usually in FeatureActivated receiver), using SPList.EventReceivers collection.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top