---
title: "Event Receiver in SharePoint 2010"  
description: "Microsoft Visual Studio 2010 provides a project type that enables you to build event receivers that perform actions before or after selected events on"  
author: "Chris Anderson"  
published: 2011-12-12  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/845/event-receiver-in-sharepoint-2010  
category: "sharepoint"  
tags: ["sharepoint"]  
reading_time: 2 minutes  

---

# Event Receiver in SharePoint 2010

[Microsoft](https://yourviews.mindstick.com/view/81711/microsoft-disconnects-cortana-and-reinvents-it) [Visual Studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available) 2010 provides a project type that enables you to build event receivers that [perform actions](https://www.mindstick.com/interview/2578/how-can-your-application-perform-actions-that-are-provided-by-other-application-e-g-sending-email) before or after selected events on a Microsoft [SharePoint](https://www.mindstick.com/articles/831/introduction-of-sharepoint-2010) 2010 site. We can create Event Receivers ([Event Handlers](https://www.mindstick.com/forum/2155/imagebutton-with-mouse-event-handlers-considered-not-well-formed)) to take care of things for us when specific things happen. For example, we can subscribe to the "ItemAdded" event for a specific list, and have our custom code execute when the event fires.\

In this article I am going to explain how to create a simple Item added event receiver for a custom list in SharePoint 2010. The event receiver will change the Title of the item to [current year](https://answers.mindstick.com/qa/115417/what-major-reforms-are-being-introduced-in-india-s-education-system-in-the-current-year) Time once it’s added to the list. We will create and deploy the solution as a farm and will run in [debug mode](https://www.mindstick.com/interview/23356/how-can-you-test-bundling-in-debug-mode).

· Open Visual Studio 2010 and create a new Project.

· In project types [select Event](https://answers.mindstick.com/qa/93829/what-is-the-select-event-in-jq-and-how-to-use-select-event-in-html-page) Receiver and give it a name.

· Select .net [framework](https://yourviews.mindstick.com/view/81101/time-for-improvement-in-healthcare-facility-framework) 3.5.

![Event Receiver in SharePoint 2010](https://www.mindstick.com/mindstickarticle/05f028f6-0d22-48e5-88bc-31f7be85c0ea/images/59bd40e7-012e-435f-b669-1259ba502d4e.png)

Next in the SharePoint Customization Wizard, choose deploy as a farm solution and specify the site URL where you want the event handler to be deployed as shown in the below figure:\

![Event Receiver in SharePoint 2010](https://www.mindstick.com/mindstickarticle/05f028f6-0d22-48e5-88bc-31f7be85c0ea/images/17edcc30-2a3c-4bc0-a107-4403e5f80c3f.png)

Next, in Event Receiver Settings dialog select the “List Item Events” as a type of event receiver and “Custom List” in the Item source dropdown. Select “An Item was Added” from Handle the following events as shown below:

![Event Receiver in SharePoint 2010](https://www.mindstick.com/mindstickarticle/05f028f6-0d22-48e5-88bc-31f7be85c0ea/images/957a2bd2-d1da-4510-a7af-7a1845157f75.png)

Next, we will write some code to change the Title of an item to the current year when it is added to a custom list.

```
using System;using System.Security.Permissions;using Microsoft.SharePoint;using Microsoft.SharePoint.Security;using Microsoft.SharePoint.Utilities;using Microsoft.SharePoint.Workflow; namespace EventHandlinginSP.EventReceiver1{    public class EventReceiver1 : SPItemEventReceiver    {        public override void ItemAdded(SPItemEventProperties properties)        {            base.ItemAdded(properties);            SPListItem _currentItem =
properties.ListItem;            _currentItem["Title"] = DateTime.Now.Year;            _currentItem.Update();        }    }} 
```

To build and deploy an application press “F5″.

Once press F5 the solution gets deployed to your site and your Visual studio project goes into a debug mode. Now we will create a new custom List “My List” and add a new item to test our handler.

##### Create List:

![Event Receiver in SharePoint 2010](https://www.mindstick.com/mindstickarticle/05f028f6-0d22-48e5-88bc-31f7be85c0ea/images/193b0965-d82c-47a3-bb44-48fea148ec5c.png)

![Event Receiver in SharePoint 2010](https://www.mindstick.com/mindstickarticle/05f028f6-0d22-48e5-88bc-31f7be85c0ea/images/da306484-6603-4c50-93c4-10e31e1c3c91.png)

\
Create a New Item -

![Event Receiver in SharePoint 2010](https://www.mindstick.com/mindstickarticle/05f028f6-0d22-48e5-88bc-31f7be85c0ea/images/5cef5322-08ee-4e95-a449-ade70fb633ef.png)

Once you add the Item you will see the results.

![Event Receiver in SharePoint 2010](https://www.mindstick.com/mindstickarticle/05f028f6-0d22-48e5-88bc-31f7be85c0ea/images/043a8636-1168-4a05-8bc0-49495f8e9ec0.png)

Thanks for reading this article. I think after reading this article you can easily implement event handler for SharePoint sites.

\

---

Original Source: https://www.mindstick.com/articles/845/event-receiver-in-sharepoint-2010

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
