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

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell