SharePoint 2010 List Events Enhancements

Have you ever worked with SharePoint 2007 List Item Events? If you have then you would have probably noticed that when we attach any event receiver with a list then it gets attached at the template level.

What I mean is, suppose I have created an event receiver for say a Calculations List which is basically a custom list (template id = 100) , so in SharePoint 2007 all events will be called for all lists which are created by using  custom list template id = 100.

And the workaround was that, we were using code to avoid this in SP 2007, like we can check the name of a list every time an event receiver gets called and execute only for the desired list.

Sample Code:

public override void ItemAdded(SPItemEventProperties properties)


  if (properties.ListTitle.Equals("YourList"))


     //here you go          



Now to avoid this in SharePoint 2010, the framework comes with some enhancements done in Event Receivers section.

Now we can associate a particular event receiver at Site / Web / List levels and so this is more granular now.

Basically there are three more attributes added for <Receivers> element and those are:

Scope: we can define the scope of Event Receiver to SiteCollection (Site) or Web level

RootWebOnly: event receiver will be attached to all lists under root web created using particular template

ListUrl: we can specify particular list on which Event Receiver will be active (/Lists/MyList/)


<Receivers ListTemplateId="100" ListUrl="/Lists/CustomList/">