That was a problem that we encountered in one of our projects. We needed to prevent some lists and libraries from being deleted even by site collection adminsitartors.
Actually there are two ways to do that :
1) Using Event Handlers
Firstly I though of extending SPListEventReceiver, I expected the presence of a function called “ListDeleting”. Unfortunately, there is no such thing as “ListDeleting”.
Ali Al-Kahki ( My ITWorx colleague ) came up with a very nice workaround listed below :
public override void ItemDeleting(SPItemEventProperties properties)
if (properties.ListItemId == 0)
properties.Cancel = true;
properties.ErrorMessage = “You are not allowed to delete the list”;
2) Using SPList.AllowDeletion
When I was exploring the SharePoint object model, I discovered a very interesting property in the SPList class. When setting this property to false, the “Delete list” option will not be displayed in the list settings page .Even if you try to delete the list programmatically an exception will be thrown as long as this property is set to false.
SPList list = web.GetList(web.ServerRelativeUrl+”/Lists/ListName”);
list.AllowDeletion = false;
I prefer the second approach but I like Ali’s workaround 🙂