Restrict the delete option from Document Library in sharepoint 2010
public override void ItemDeleting(SPItemEventProperties properties)
{
using(SPSite site = new SPSite(properties.SiteId))
{
using(SPWeb web = site.OpenWeb(properties.RelativeWebUrl))
{
if(properties["Title"] == "SomeTitle")
return;
properties.Cancel = true;
properties.ErrorMessage = "You cannot delete item";
}
}
}
Comments
Post a Comment