I'm trying to get create an ItemUpdating event that checks for some potentials issues in a couple of lists. However the item event does not seem to be triggering at all, even debugging the call to ItemUpdating( .. ) does not work, it is as if the method is never called.
Event code:
namespace MyEvent.EventReceiver1
{
public class EventReceiver1 : SPItemEventReceiver
{
public override void ItemUpdating(SPItemEventProperties properties)
{
base.ItemUpdating(properties);
// ... my code testing column BeforeProperties vs AfterProperties
if (properties.ListTitle == "My List")
{
if (properties.BeforeProperties["some field"] != properties.AfterProperties["some field"])
{
properties.Cancel = true;
properties.ErrorMessage = "Please do not alter some field in my list";
}
}
}
}
}
If I debug "public override void ItemUpdating()" it never fires when updating a list- rather it is "My List" or not. So my check is never run even if "My List" updates an item.
My elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListTemplateId="100">
<Receiver>
<Name>EventReceiver1ItemUpdating</Name>
<Type>ItemUpdating</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>MyEvent.EventReceiver1.EventReceiver1</Class>
<SequenceNumber>10000</SequenceNumber>
</Receiver>
</Receivers>
</Elements>
Note that this event receiver is quite a bit more complex in reality.. it fires on several different events with some fairly in-depth functionality. Everything else in the feature works fine except the above ItemUpdating and ItemDeleting methods.