Learn What is Event handler in SharePoint? How to use it in a SharePoint site?
I will create an event handler which will avoid deletion from a document library in your SharePoint site.
Follow these steps for Event handler:
Open Visual studio, File-New-Project
Choose C# as your language and Class library from the template section.
So before writing the code you need to add few references. Right click on your solution and select Add Reference... From .net tab select Windows SharePoint Services and Microsoft SharePoint.
Add this namespace in your class library:
public class eventhandlersample:SPItemEventReceiver
public override void ItemDeleting(SPItemEventProperties properties)
properties.Cancel = true;
properties.ErrorMessage = "Sorry! You can't delete items from this library";
Now build your application. It should succeed, if yes then fine. (Do not run your application now)
Open project menu from Visual studio, select your project name from the menu.
From new window select Signing tab, select the checkbox "sign the assembly" and from dropdownlist select new and provide a name. Leave it as it is for other options. Build your solution again.
Locate this path: C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Your project name\your project name\bin\Debug
Drag .dll file of your project name in to C:\Windows\assembly
Go to this location.
Program Files/Common Files/Microsoft Shared/web server extensions/12/TEMPLATE/FEATURES
Create a folder EventHandler.
In this folder create 2 xml files.
<Feature Scope="Web" Title="Event Handler To avoid Delete" Id="1F579D91-4F4B-4389-B03B-7A92EF2EE210" xmlns="http://schemas.microsoft.com/sharepoint/">
<Assembly>DeletingEventHandler1, Version=188.8.131.52, Culture=neutral,
Open command prompt and prompt to
C:/Program Files/Common Files/Microsoft Shared/web server extensions/12/BIN
Type below commands one by one
Your task is completed now. Open your sharepoint site create a new document library, add few documents and try to delete any one of them. It will give you a warning message that you can delete.
Note: It will work for all document libraries of specified url.
Do not forget to give your valuable feedback.
SharePoint Event Handlers Manager allows admins to browse, add, edit and remove SharePoint event handlers from any list or web. This SharePoint solution provides two features that enables admins to play with event handlers from within SharePoint interface.
create a SharePoint Foundation event handler in Visual Studio, produce a replacement project of sort "class library" and so inherit from one among the event receiver base categories. once you choose the event receiver base category from that to inherit, make certain that your event receiver base is acceptable for the event you propose to capture and for the event host to that you propose to bind.
Sharepoint provides legion inbuild options for storing documents, managing information, making sub sites. you'll be able to produce your own lists, documents libraries, announancement, calendar. every list has its own events i.e Item Created, Item Updated Item Deleted etc. however if you would like to try and do some factor on any event, you wish to put in writing custom code for this. this may be done by exploitation Event handlers.
Event handler is occuring once some action happened in SharePoint web site. e.g. you're adding AN item to sharepoint list, you're deleting item from sharepoint list etc. primarily there square measure four sorts of categories obtainable for event handler.
• List things – SPItemEventReceiver
• List Columns – SPListEventReceiver
• web site – SPWebEventReceiver
• Email – SPEmailEventReceiver