You need to disable the event reciver by calling it and setting it to disabled. do your stuff and reenable the eventreciver:
someone has done most of the work for you :)
public static void RunWithEventFiringDisabled(Action action)
{
Type typeInfo = typeof(SPEventReceiverBase);
MethodInfo disable = typeInfo.GetMethod(“DisableEventFiring”, BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo enable = typeInfo.GetMethod(“EnableEventFiring”, BindingFlags.Instance | BindingFlags.NonPublic);
SPEventReceiverBase receiver = new SPEventReceiverBase();
try
{
//disable it
disable.Invoke(receiver, null);
//do what you want to do to the list in this method
action();
}
finally
{
//now updating is all done you can reenable it
enable.Invoke(receiver, null);
}
}
code was taken from here:
www. sharepointboost .com/blog/how-to-update-an-item-or-a-folder-without-triggering-item-event-receiver/
For you or anyone you could split it into to methods where you can call the enable and disable individually
for disabling:
public static void RunWithEventFiringDisabled(Action action)
{
Type typeInfo = typeof(SPEventReceiverBase);
MethodInfo enable = typeInfo.GetMethod(“EnableEventFiring”, BindingFlags.Instance | BindingFlags.NonPublic);
SPEventReceiverBase receiver = new SPEventReceiverBase();
try
{
//disable it
enable.Invoke(receiver, null);
//do what you want to do to the list in this method
action();
}
cathc(exception a)
{
}
}
and for enabling:
public static void RunWithEventFiringEnabled(Action action)
{
Type typeInfo = typeof(SPEventReceiverBase);
MethodInfo disable = typeInfo.GetMethod(“DisableEventFiring”, BindingFlags.Instance | BindingFlags.NonPublic);
SPEventReceiverBase receiver = new SPEventReceiverBase();
try
{
//disable it
disable.Invoke(receiver, null);
//do what you want to do to the list in this method
action();
}
cathc(exception a)
{
}
}
call those two where required :)
EDIT
You could also try this as its just as good :) call this method where required instead of normal updating
public static void Update(this SPListItem item, bool doNotFireEvents)
{
SPItemEventReceiverHandling rh = new SPItemEventReceiverHandling();
if (doNotFireEvents)
{
try
{
rh.DisableEventFiring();
item.Update();
}
finally
{
rh.EnableEventFiring();
}
}
else
{
item.Update();
}
}
http://sharepointlookup.blogspot.co.uk/2010/12/updating-splistitem-without-triggering.html#!/2010/12/updating-splistitem-without-triggering.html