n
nHave you ever worked with SharePoint 2007 List Item Events? If yes then you would have probably noticed that when we attach any event receiver with list then it gets attached at the template level
n
nwhat I mean is suppose I have created an event receiver for say 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
n
nand workaround was that , we were taking help of code to avoid this in SP 2007 , like we can check the name of list every time event receiver gets called and make execution only for desired list
n
nSample Code:
n
npublic override void ItemAdded(SPItemEventProperties properties)
n
n{
n
n if (properties.ListTitle.Equals(“YourList”))
n
n {
n
n //here you go
n
n }
n
n}
n
nNow to avoid this in SharePoint 2010, framework comes with some enhancements done in Event Receivers section
n
nNow we can associate particular event receiver at Site / Web / List levels and so this is more granular now
n
n Basically there are three more attributes are added for <Receivers> element and those are
n
nScope: we can define the scope of Event Receiver to SiteCollection (Site) or Web level
n
nRootWebOnly: event receiver will be attached to all lists under root web created using particular template
n
nListUrl: we can specify particular list on which Event Receiver will be active (/Lists/MyList/)
n
nExample:
n
n<Receivers ListTemplateId=“100“ ListUrl=“/Lists/CustomList/“>
n
n <Receiver>
n
n <Name></Name>
n
n <Type></Type>
n
n <Assembly></Assembly>
n
n <Class></Class>
n
n <SequenceNumber></SequenceNumber>
n
n </Receiver>
n
n </Receivers>
n