Do you use field and list item validation (in 2010)
Last updated by Brady Stroud [SSW] 8 months ago.See historyclass CreateShoppingListHandler : SPItemEventReceiver
{
public override void ItemAdding(SPItemEventProperties properties)
{
float price = 0;
float cost = 0;
if(float.TryParse(properties.ListItem.Fields["Price"].ToString(), out price) && float.TryParse(properties.ListItem.Fields["Cost"].ToString(), out cost))
{
if(price < cost)
{
properties.ErrorMessage = "The cost must not be less than the price";
properties.Cancel = true;
}
}
}
}
Bad example: using custom code – creating a custom event receiver on the item (the item adding event or item updating event)