Monday, July 19, 2010

Creating Event receiver as a Feature for Sharepoint List

1)Go to The below path

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES

2)Create New Folder name called like

3)IN that folder Create two xml files

a)Feature.xml
b)Elements.xml

Note:(if you dont have option to create xml you can create .txt and rename like Feature.xml)

4)Open Feature.xml file and write the below code.


Id="EA7B9712-F6DA-47e7-A13A-7EBDFC348340"
Scope="Web"
Title="EventReceivers_TempTasks"
Hidden="FALSE"
Version="1.0.0.0"
Description="Activate Feature">





In the above code

ID=New GUID(you can create new guid using visual studio--> tools-->GUID
Scope=Creating feature for scope of the sharepoint portal ,whether it is sitecolection or subsite. If it is "Web"-->Avalable for subsite
"Site"-->Available for site collection

Title=Title of the Feature Name it will display while activating

In the Elements manifests we will add elemensts avaialble in that feature.
In this example we have only one elemensts.xml

if we have two elements.xml files we need to add that elements as like below





Note:The name of the element file name might have any name like sample.xml or test.xml
5)Save and close Feature.xml file
6)open the Elements.xml file and write the below code



ItemAdding
ItemAdding
10001
DemoEventReceivers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d4e8eb189dba459d
DemoEventReceivers.ClassName






In the above code we are writing event for type tasks List,
Type of ID for Tasks is "107"
ListTemplateOwner is event for particular list Here we will mention list ID
ListTemplateOwner="{D8632C31-D30F-4749-857E-ADFBA1BC4751}"
(Note:Finidng list ID:)

Type: event for list
:Event recevier(Dll) for the list
(Note:Creating dll for the list
)

class name in the eventreceivers(dll)
7)Save and close elements.xml

Creating Feature is complete

To Install and Activate Feature

No comments:

Post a Comment

Content Editor Webpart not showing up in SharePoint Online ------------------------------------------------------------------------------...