I'm looking for a way to implement programmatically vallidation for NewListItems/EditListItems.
One way I found was: to use the ListEvents and Validate on ItemAdding / ItemEditing. But instead of a clean Errormessage I just get a Server Error Page.
public override void ItemAdding(SPItemEventProperties properties)
{
base.ItemAdding(properties);
if (properties.AfterProperties["a"].ToString() == properties.AfterProperties["v"].ToString())
{
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.Cancel = true;
properties.ErrorMessage = "Error-Message";
}
}
Perhabs someone has en idea how to solve this problem. Thanks a lot.