We often comes across many situations where we need to disable the event firing on item edit.
Here is a simple trick to do that.
First, create a class which inherits from SPItemEventReceiver class and IDisposable interface as shown below
class DisableEventFiring : SPItemEventReceiver, IDisposable
{
bool bEvent;
public DisableEventFiring()
{
bEvent = this.EventFiringEnabled;
this.EventFiringEnabled = false;
}
public void Dispose()
{
this.EventFiringEnabled = bEvent;
}
}
Now just use this class for disabling the event firing like shown below:
using(new DisableEventFiring())
{
_item.update;
}
Here is a simple trick to do that.
First, create a class which inherits from SPItemEventReceiver class and IDisposable interface as shown below
class DisableEventFiring : SPItemEventReceiver, IDisposable
{
bool bEvent;
public DisableEventFiring()
{
bEvent = this.EventFiringEnabled;
this.EventFiringEnabled = false;
}
public void Dispose()
{
this.EventFiringEnabled = bEvent;
}
}
Now just use this class for disabling the event firing like shown below:
using(new DisableEventFiring())
{
_item.update;
}
No comments:
Post a Comment