How to redirect a user to a custom page after adding a new List Item

This took me a while to figure out how to do this so I thought I’d share my experience.

Problem:
User needs to perform additional tasks after a new list item has been added to a list. I my case, I wanted the user to create a new list item of information that needed to be emailed to a certain group of people, based on what he/she selected in the new list item form.

Solution:
Create an Event Handler for the list and overriding the ‘ItemAdding’ method to:
(more…)

Adding an attachment to a SharePoint list item programmatically

I needed a way to upload an attachment to a list item within an Event Handler but discovered it was not that simple. Now that I have the code to add attachment to a list item, I don’t want to lose it.

The following code can be called from a web part or an application page easily. What was complicated for me was trying to attach a file from the ItemAdding/ItemAdded Event Handler.
(more…)

Creating a new SharePoint Event Handler

Creating a new SharePoint Event Handler consists of the following steps:

* create a new class library project
* add the Microsoft.SharePoint reference
* add a using statement for Microsoft.SharePoint;
* inherit the class from SPItemEventReceiver
* add the override classes desired (more…)