Add the Microsoft.SharePoint reference and using statement to your newly create project.
Derive your class from SPItemEventReceiver
e.g. public class MyEventAction : SPItemEventReceiver
Override the required *ed or *ing function(s) out of the list required for your project:
ItemAdded
ItemAdding
ItemAttachmentAdded
ItemAttachmentAdding
ItemAttachmentDeleted
ItemAttachmentDeleting
ItemCheckedIn
ItemCheckedOut
ItemCheckingIn
ItemCheckingOut
ItemDeleted
ItemDeleting
ItemFileConverted
ItemFileMoved
ItemFileMoving
ItemUncheckedOut
ItemUncheckingOut
ItemUpdated
ItemUpdating
e.g.
public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);
}
Create a folder that syncs to the hive location under templates then features then create a folder with the name of the feature and in it create a xml file called Feature.xml
Update the Feature.xml to look sorting like the following.
<Feature Scope="Web" Title="My Event Handler"
Id="GUID" xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="Elements.xml"/>
</ElementManifests>
</Feature>
Now create an Elements.xml file in the MyEventHandler folder that identifies the assembly, class, and method to implement as the event handler.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListTemplateId="104">
<Receiver>
<Name>MyEventHandler</Name>
<Type>ItemAdded</Type>
<SequenceNumber>10000</SequenceNumber>
<Assembly>MyEventHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a26b5449ac4a4cf3</Assembly>
<Class>MyEventHandler.AddedAction</Class>
<Data></Data>
<Filter></Filter>
</Receiver>
</Receivers>
</Elements>
The Type attribute ListTemplateId is for the type of list this action applies to:
| ID | Name |
| 100 | Generic list |
| 101 | Document library |
| 102 | Survey |
| 103 | Links list |
| 104 | Announcements list |
| 105 | Contacts list |
| 106 | Events list |
| 107 | Tasks list |
| 108 | Discussion board |
| 109 | Picture library |
| 110 | Data sources |
| 111 | Site template gallery |
| 112 | User Information list |
| 113 | Web Part gallery |
| 114 | List template gallery |
| 115 | XML Form library |
| 116 | Master pages gallery |
| 117 | No-Code Workflows |
| 118 | Custom Workflow Process |
| 119 | Wiki Page library |
| 120 | Custom grid for a list |
| 130 | Data Connection library |
| 140 | Workflow History |
| 150 | Gantt Tasks list |
| 200 | Meeting Series list |
| 201 | Meeting Agenda list |
| 202 | Meeting Attendees list |
| 204 | Meeting Decisions list |
| 207 | Meeting Objectives list |
| 210 | Meeting text box |
| 211 | Meeting Things To Bring list |
| 212 | Meeting Workspace Pages list |
| 300 | Portal Sites list |
| 301 | Blog Posts list |
| 302 | Blog Comments list |
| 303 | Blog Categories list |
| 1100 | Issue tracking |
| 1200 | Administrator tasks list |
| 2002 | Personal document library |
| 2003 | Private document library |
Save and build project.
Deploy using STSADM.
stsadm -o installfeature -filename MyEventHandler\Feature.xml stsadm -o activatefeature -filename MyEventHandler\Feature.xml -url http://Server/Site/Subsite
Then you will have to do and iisreset using cmd
iisreset -noforce
For more information see:
http://msdn.microsoft.com/en-us/library/ms453149(v=office.12).aspx
No comments:
Post a Comment