How to add Event Receiver to two lists. One must be actualizing when in the secound element add's.
I Use public override void ItemAdding(SPItemEventProperties properties)
But what should i put in this method ?
|
How to add Event Receiver to two lists. One must be actualizing when in the secound element add's. I Use public override void ItemAdding(SPItemEventProperties properties) But what should i put in this method ? |
|||
|
|
|
Grzegorz, What happens with Event Receivers, in the receiver in feature XML has a ListTemplateId which determines to which List template the event receiver is for... So lets say you need to add event receiver on custom list then ListTemplateId=100 or you want to add to Announcements template the ListTemplateId=104, like below:
Now if you attach event receiver to custom list template, the event will fire for every custom list you have in the scope! And you can identify the list in code by using properties... the SPItemEventProperties has a property called List.. which give you SPList, and you can either by GUID or Name identify the list and perform operation accordingly... What I do is create a SWITCH-CASE for different lists and perform operations according in the cases! I hope this answered and clarify the concept of Event Receivers, you can read more over here and here So when you have deployed the event receiver it will fire for both the lists, and you will first identify for which list it has been fired.. then code accordingly! Arsalan Adam Khatri |
|||||||||||
|