Create SharePoint event receiver for sepcifc list

Standard

When you create a new SharePoint event receiver from Visual Studio the Visual Studio asks you “What item should be the event source” – ” see image below”

For example if you choose the list template “Survey” that means your event receiver will applied in all lists from the type survey , but in the real work you need to specify a list instance which the event receiver will apply to it .

VS event receiver - event source

VS event receiver – event source

 

 Event Receiver For Specific List

1-From Visual Studio solution explorer open the “elements.xml” file for the event receiver “see image below”

Element.xml

Element.xml

2-You will find an attribute “ListTemplateId” in the “Receivers” element   “see image below”

ListTemplateId attrbuite

ListTemplateId attrbuite

3-The value for “ListTemplateId” attribute is refer to the type of the list which you chosen from Visual Studio and each list template has a unique template id for example “announcements” list template id is “104” – to find table of all list template IDs Click here

4-Replace the attribute  “ListTemplateId”  with another attribute  “ListUrl”  and the value will be “Lists/<ListName>” – for example ListUrl=”Lists/test” – “see image below”

ListUrl attrbuite

ListUrl attrbuite

5-Deploy and that’s it 🙂

Thanks

Advertisements

One thought on “Create SharePoint event receiver for sepcifc list

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s