In a Document library I have a content type say "ABC" and I have added an eventhandler to it. I have itemdeleting so that user can not delete file for specific reason. Problem comes when user makes a folder and put files inside that folder. If folder has many files of that content type user can delete entire folder and event handler doesn't work. Event does not fire to stop user. It was working fine in sharepoint 2007. For the solution I tried to make a content type derived from folder and added eventhandler to "myFolder" content type but events are fired only at item adding and item updating not on itemdeleting. I want to stop user from deleting folder. Please Help...
You can create custom folder content type, and attach the event handler to it.
This can be done through GUI: Site Actions => Site Settings => Galleries => Site content types => Create
Then, you should go to your list/library settings, enable content type management in Advanced settings, and finally add your newly created content type to the list/library:
After all this done, you can attach an event receiver to your custom folder content type, for example, using
Not tested, but should work.
Create a permission level that does not allow users to delete items. Apply that permission level to the users for that document library. No reason to do this with code. Functionality exists purely OOTB.