An event receiver created in Visual Studio using the SharePoint project template. Below are the step to create a simple Item added event receiver, which creates a new item in another list.
Open Visual Studio 2016 and create an Empty SharePoint Project.
Enter site URL and select Deploy as a farm solution and click Finish.
Add a new item to the project. Right click project and select Add -> New Item -> Event Receiver.
Select event receiver and enter the title of the event receiver. Click the Add button.
Add below code in eventreceiver1.cs
public override void ItemAdded(SPItemEventProperties properties)
SPWeb aWeb = properties.Web;
SPList alist = aWeb.Lists[“et”];
SPListItem aItem = alist.Items.Add();
aItem[“Title”] = properties.ListItem[“Title”];
aItem[“Name”] = properties.ListItem[“name”];
aItem[“salary”] = properties.ListItem[“salray”];
In the above code I created list called “et”, I am adding data to this list using below code,
once user add data in to “event list” this event receiver copy the item in to “et” list.
the Item Added method is used instead of the Item Adding method.
Go to Elements.xml update receivers tag.
In the elements.xml you can see receivers tag listtemplateid replace that with ListUrl=”Lists\listname”
Right click on the solution click deploy.