Approach:
Listeventreceivers = new List ();
foreach (SPEventReceiverDefinition EventReceiver in list.EventReceivers)
{
eventreceivers.Add(EventReceiver);
}
foreach (SPEventReceiverDefinition er in eventreceivers)
{
er.Delete();
}
Note: We can not have only 2nd foreach loop alone. The current list of event receivers associated to a list gets updated everytime a delete operation is performed. So, an exception will be raised if you use only delete operation.
No comments:
Post a Comment