Home > Deveploment and Programming, SharePoint Development > Disable Event firing in webpart code in Sharepoint

Disable Event firing in webpart code in Sharepoint

Hi All,

There are very simple approach the same, as you can see below code

Step 1. Create one class

public class DisableEventFiring : SPItemEventReceiver, IDisposable{
  public DisableEventFiring()
  {
   base.EventFiringEnabled = false;
  }

  void IDisposable.Dispose()
  {
   base.EventFiringEnabled = true;
  }
}

Step 2. use the class while adding or update the item value.

objDocItem[“Title”] = “Sanjiv”;

using(DisableEventFiring threadScope = new DisableEventFiring())
{
    objDocItem.Update()
}

 

 

Ref:

http://www.directsharepoint.com/2011/03/disable-enable-event-firing.html

 

Advertisements
  1. Srivatsa
    13/12/2012 at 2:27 pm

    Good one.. It helped me a lot

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: