Disable all event receivers in SharePoint 2010
I found the following page( here ) about disabling global event receivers. A fantastic post that solves a very specific need.
The crux of the solution is as follows:
public class MyClass
{
SPListItem i = SPContext.Current.Web.Lists["Blah"].Items[0]
HandleEventFiring handleEventFiring = new HandleEventFiring();
handleEventFiring.DisableHandleEventFiring();
try
{
i.Update();
}
finally
{
handleEventFiring.EnableHandleEventFiring();
}
}
public class HandleEventFiring : SPItemEventReceiver
{
public void DisableHandleEventFiring()
{
this.EventFiringEnabled = false;
}
public void EnableHandleEventFiring()
{
this.EventFiringEnabled = true;
}
}
The crux of the solution is as follows:
public class MyClass
{
SPListItem i = SPContext.Current.Web.Lists["Blah"].Items[0]
HandleEventFiring handleEventFiring = new HandleEventFiring();
handleEventFiring.DisableHandleEventFiring();
try
{
i.Update();
}
finally
{
handleEventFiring.EnableHandleEventFiring();
}
}
public class HandleEventFiring : SPItemEventReceiver
{
public void DisableHandleEventFiring()
{
this.EventFiringEnabled = false;
}
public void EnableHandleEventFiring()
{
this.EventFiringEnabled = true;
}
}
Comments
Post a Comment