How to associate an Event Handler to a particular list?

 Posted by Bhanubysani on 3/17/2014 | Category: SharePoint Interview questions | Views: 1114 | Points: 40
Answer:

If you are writing an event handler on list or library it will prompt for select the list type.

If you select announcements, tasks or any custom list. Generally it will run on the lists which have the same template id.

To avoid Event handlers to running on all the lists of similar template ids

Go to Elements.XML file of the event receiver

When you create Event Receivers in your solution in Visual studio you will have the following line added

<Receivers ListTemplateId="101">


Template id will be different type for different type of lists.

But our scenario is list template id is same but we need to run on particular list, so we need to replace that line with below line.

<Receivers ListUrl="Lists/Customlist">


This directs the event receiver to respond only to events that occur in the Customlist. You can change the ListURL attribute to reference any list instance on the SharePoint server.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response

More Interview Questions by Bhanubysani