This article provides a detailed steps for creating a list event receiver in SharePoint. Although the steps explained are related to SharePoint 2010, its same for SharePoint 2013 too.
Follow the below steps to create an event receiver for a SharePoint List.
Open visual studio 2010 and create empty SharePoint project.
Enter the SharePoint URL in SharePoint customization wizard, Choose Deploy as a sandboxed solution and click Finish.
Right click the project and select Add new Item and select create event receiver and click ok. This would open up Event Receiver Settings Wizard
In the event receiver settings dialog select the “List Item Events” as a type of event receiver and “custom List” in the item source drop down. Select “An Item was Added” from Handle the following event and click finish.
In the event receiver class of list , add the below mentioned code. This is just a simple example to change the title to current date.
public override void ItemAdded(SPItemEventProperties properties)
SPListItem _currentItem = properties.ListItem;
_currentItem["Title"] = DateTime.Now.ToString();
Now build and deploy the project to the SharePoint
In SharePoint Site click Site Actions => Site Settings => Galleries =>Solution and verify that your solution is now deployed to the site.
Create a new Custom List “Test Event Receiver” and Add a new item to test the project and click Add.
Create new item and enter “Test Item” in the Title text box
Once you add the item and refresh the custom list page , you can see the results as date and time as we have updated the data in event receiver.