SharePoint Pals
 | Sign In
How to create a custom list level event receiver in SharePoint 2013 and SharePoint 2010
by Gopal Muthukrishnan 20 Apr 2013
Author
SharePoint Developer, SharePoint Frontier
Visits   
Today  :   23     Total  :    44959

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.

Step 1:

Open visual studio 2010 and create empty SharePoint project.

Step 2:

Enter the SharePoint URL in SharePoint customization wizard, Choose Deploy as a sandboxed solution and click Finish.

clip_image002

Step 3:

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

Step 4:

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.

clip_image004

Step 5:

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)
{
base.ItemAdded(properties);
SPListItem _currentItem = properties.ListItem;
_currentItem["Title"] = DateTime.Now.ToString();
_currentItem.Update();
}

Step 6:

Now build and deploy the project to the SharePoint

Step 7:

In SharePoint Site click Site Actions => Site Settings => Galleries =>Solution and verify that your solution is now deployed to the site.

clip_image006

clip_image008

Step 8:

Create  a new Custom List “Test Event Receiver” and Add a new item to test the project and click Add.

clip_image010

Step 9:

Create new item and enter “Test Item” in the Title text box

clip_image012

Step 10:

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.

clip_image014

blog comments powered by Disqus

SharePoint Pals

Pals
SharePoint Pals, a community portal for SharePoint developers, Administrators and End Users. Let's join hands and share the point together.
Read this on mobile

Training

Angular Js Training In Chennai
Advanced Angular Js training with real world developer scenarios
Angular Js, Web Api and Ionic for .Net Developers
All in one client side application development for .Net developers
Angular Js For SharePoint Developers
Get ready for the future. Its no more just C#

Get Connected

SharePoint Resources

SharePoint 2013 and 2010 Web Parts
Free Web Parts with Source Code for SharePoint Community




SharePoint 2013 Books and Tutorials
Collection of free SharePoint 2013 books and tutorials (eBooks, pdfs)

Supported By

Contribute your article and be eligible for a one month Free Subscription for Plural Sight. The Author of the most popular New Article (published in the previous month) will be awarded with a Free One month Plural Sight Subscription. Article can be sent to articles@sharepointpals.com in a word document.

Related Resources

Recent Tweets

Twitter January 15, 00:25
How To Enable Target Value And Actual Value In #D3 Gauge Chart https://t.co/VxSi4QnNrC

Twitter January 15, 00:24
How To Open #SharePoint List Hyperlink Column In Modal #Popup Window https://t.co/EQ7HkoZDkX

Twitter January 15, 00:24
Quick Introduction To #Asp.NetCore And It’s Features https://t.co/zAXObHCFpH

Twitter January 15, 00:22
How To Configure #PerformancePoint Services To Use Secure Store In #SharePoint 2013 https://t.co/LEwnUoI7EY

Twitter January 15, 00:21
How To Block Or Disable #Office365 Services https://t.co/Yvp2VPFIRP

Follow us @SharePointPals
Note: For Customization and Configuration, CheckOutRecent Tweets Documentation