I am writing a feature in sharepoint. What i need to do is when the feature in activated i need to enable some event recievers..If the feature is deactivated the receivers should stop working.
ie if the feature is currently activated and user tries to add some values to a lists named say "My Tasks", i need to execute some code before the item is added (ItemAdding ?)
In the element manifest file, i need to add
How can i specify that the receiver that is there should work only for the list named "My Tasks"

Bhushan GawalePosted Mar 23, 2011, 2:38 AM
you can directly add check for list name in your receiver class like this
if (properties.ListTitle.Equals("YourListTitle"))
{
//Your Code Here
}
because I guess event receivers gets attached at the list template levels , so for example , If you are attaching SPListItemEventReceiver (ItemUpdating for example) on custom list type then this will be for all lists which are created by using custom list template
and If you are working with SP 2010 then you can take advantage of some list event enhancements
here is my article on this
hoep this helps you :)
Prasham SabadraPosted Mar 22, 2011, 7:45 AM
I had the same sitiuation like you some time before. What we did we put the condition in event receiver. We put the condition for content type. i.e. If current items content type(I guess listitem.ContentType) is same as list content type. If this condition is true then only execute code.
Please free to ask if you will require further details.
Thanks
Prasham
Suthish NairPosted Mar 20, 2011, 12:00 PM
Contact Destin Joy, he is good in Sharepoint might helps you.