Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer
    
ListUrl works only if feature has Scope=”Web”. In case the feature has Scope=”Site”, event receiver is fired for every list, ListUrl is ignored. –  Amit Kumawat Jan 3 '12 at 17:31

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.