SharePoint List Event Handlers

One of the extremely powerful feature of SharePoint is the ability to create event receivers for any list type.

An event receiver is a piece of managed code that is launched in response to an event takes place within SharePoint. These events can be triggered in response to changes to list items, creation of new lists items, list items being deleted and much more.

List event handlers are made possible through the concept of event receivers.
An event receiver is a .NET framework class contained in the strong-typed assembly in GAC.

One of the prime examples of using event receivers is to log the entries for admin purpose to track the changes to list data.

Here are the steps to create your own event receivers.

1. Create a class that inherits from SPListEventReceiver or from SPItemEventReceiver.
2. Strong name the assembly.
3. Deploy assembly to GAC
4. Deploy the event receiver with code to SharePoint.

Sample List Item Event Receiver Code

Using system;
Using system.IO;
Using system.Text;
Using Microsoft.SharePoint;

namespace EventLog
Public class LogEvent : SPItemEventReceiver
Public override void ItemAdded(SPItemEventProperties properties)
WriteTextToLog(String.Format(“[{0}] Item added: {1}”, properties.ListItem.Title,DateTime.Now.Tostring()));
Public override void ItemDeleted(SPItemEventProperties properties)
WriteTextToLog(String.Format(“[{0}] Item deleted: {1}”, properties.ListItem.Title,DateTime.Now.Tostring()));
Public void WriteTextToLog(string text)
StreamWriter file = File.AppendText(@“c\SharePointlog.txt”);
file.write(text + "\n");

Check out for more list/item events at
After you have written your event receivers you can follow steps 2 and 3 mentioned above.
I will explain in my next article how you can deploy the event receiver to SharePoint using code.


Author: Sagar03 Jun 2009 Member Level: Gold   Points : 2

Sorry to see the rejection. But I dont see any copy from the URL you gave. Only line that is present is definition about the event receivers which you will find in any book of SharePoint or the material.
Did you find any other thing thats matching my article?
I am seeing the URL for the first time.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: