Sharepoint - SPItemEventReceiver ItemUpdating and BeforeProperties / AfterProperties

Have you tried:

string BeforeValue = properties.ListItem[internalName];

instead?

BeforeProperties is a weird beast, I try to avoid using it.


First of all, I would recommend having this page open at all times while developing an event receiver. The important part for you, is the Document library table:

Library         BeforeProperties    AfterProperties    properties.ListItem
ItemAdding      No value            No value           Null
ItemAdded       No value            No value           New value
ItemUpdating    Original value      Changed value      Original value
ItemUpdated     Original value      Changed value      Changed value
ItemDeleting    No value            No value           Original value
ItemDeleted     No value            No value           Null

Also, if you are going to try to compare Before/After values, watch out for these types: People fields, rich text fields (Note), and DateTime fields. I'm sure this is probably a subset so make sure you test.

Tags: