@eirikb: Unfortunately, there is a "minor" problem with this approach. Although it is not well documented, the property has (wisely) no global effect. It does not disable all of the event receivers in the farm, nor does does it disable triggering event receivers in the current list for activities occured on other threads. It has a scope local to the current tread. See this answer for reference. What does it mean for us? If you create and call a custom web service that sets the EventFiringEnabled property, it has effect only in the scope ot that call, but has no effect at all of your code executed from the client object model.
Is there a way in the Client Object Model to disable, or remove and
add the list event handler?
So as far as I know, you cannot disable the event receiver from the client object model. But in SP 2013 you can remove and add the event receiver. If you need to limit the effect of this change to your current process, use this approach only if you are absolutely sure your process is the only one that alters data in your list!
To remove, you should call the deleteObject method of the corresponding SP.EventReceiverDefinition instance.
List list = web.Lists.GetById(listId);
EventReceiverDefinition eventReceiver = list.EventReceivers.GetById(yourEventReceiverId);
eventReceiver.DeleteObject();
clientContext.ExecuteQuery();
You can add a new handler via the add method of the SP.EventReceiverDefinitionCollection, passing an SP.EventReceiverDefinitionCreationInformation instance as parameter.
List list = web.Lists.GetById(listId);
list.EventReceivers.Add(new EventReceiverDefinitionCreationInformation {
EventType = EventReceiverType.ItemUpdated,
ReceiverName = "MyRemoteEventReceiverItemUpdated",
ReceiverClass = "Your.Namespace.YourClass",
ReceiverAssembly = "Strong Name Of Your Assembly",
SequenceNumber = 10000}
);
list.Update();
clientContext.ExecuteQuery();