Sharepoint 2010 Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint 2010       RSS Feeds

list event receiver firing for ALL lists

  Asked By: Harshita    Date: Sep 23    Category: Sharepoint 2010    Views: 8466

Using VS2010 and SharePoint 2010, defined content types, list definitions, and
list instances declaratively. Added EventReceiver (ItemAdded) project item,
pointed to specific list template, deployed. Receiver fires for every list on my
site. the receiver is defined declaratively:

<Receivers ListTemplateId="10000">


Does ListTemplateId not work? I could have used ListUrl but I'm just wondering
why ListTemplateId doesn't seem to work. Ideas?



6 Answers Found

Answer #1    Answered By: Indu Raj     Answered On: Sep 23

Try ListTemplateId="100" 100 is for custom lists, 107 is for task lists, etc.

I can only speak from 2007 experience, but I believe it still applies to 2010.
Event handlers are scoped to the site (SPWeb), not to a specific list. Unless
the underlying code works differently in 2010, you'll need to check for the list
name. Below is an example I use for the ItemAdded event in my 2007 code:

// Prevent the accidental triggering of events from logic
in this method.

// Get the List Name in which this event was
string strListName = properties.ListTitle;
switch (strListName)
case "Vehicle":
this.ItemAddedVehicle(properties); break;
case "Monthly":
this.ItemAddedMonthly(properties); break;
default: break;
catch (Exception ex)
// Add Exception handling here

// Re-Enable event trigggering

Answer #2    Answered By: Khushi Srivastava     Answered On: Sep 23

I thought you could scope to a list in 2010. Anyone know?

When I add the event receiver to my project and specify the list in the wizard,
VS automatically adds the ListTemplateId=”1000” because the list template I
chose had an ID of 1000. Maybe you have to use the ListUrl attribute to bind to
a specific list?

Answer #3    Answered By: Arti Patel     Answered On: Sep 23

Well it appears there was just something buggered up in my project to cause the
event receiver to get bound incorrectly. I created a sample project and it
worked fine. Setting the ListTemplateId attribute will bind the event receiver
to all lists created with that template, either in the web or site collection
depending on the scope.

Answer #4    Answered By: Claire May     Answered On: Sep 23
Answer #5    Answered By: Dan Dickerson     Answered On: Sep 23

to bind to a specific list, use List GUID.

Nothing has changed from 2007 to 2010 for event handlers scoping except for the
addition of a number of new event handlers.

Answer #6    Answered By: Phenil Poriya     Answered On: Sep 23

Actually, one thing has changed since you can now bind an event handler to a
specific list and not just to a list type. 2010 added a ListUrl attribute to
the Recievers element of a feature used to bind an event handler to a list.
Take a look at the new definition here:


Didn't find what you were looking for? Find more on list event receiver firing for ALL lists Or get search suggestion and latest updates.