Cannot delete Document Library until delete all items - Event Receiver

How can i control this. 

The user click on delete document library but this document library have documents.!! So i want stop the action and send a message "The DL have files, please del first documents."



I think one way to do this is using event receiver. 

Something like this: 

public override void ListDeleting(SPListEventProperties properties)
        {
            if (properties.List.Items.Count != 0)
            {
                properties.Status = SPEventReceiverStatus.CancelWithError;
                properties.ErrorMessage = "The DL have files!!'";
            }
            base.ListDeleting(properties);
        }

But im not having sucess!! Any help. 

Thanks


August 30th, 2013 6:37am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics