Ive already read this question how to attach an event receiver to a custom list in sharepoint? but I have a doubt.
When I use the EventReceivers.Add
method to attach my event receiver, does the event receiver feature must be activated, or is it enough to have it installed?
And, if it has to be installed, what ListTemplateId should I use in the elements.xml of the event feature?
Thanks in advance
The event receiver is a definition. The definition maps to an assembly and class instance. Using a feature for event receiver association declaratively(specifying listtemplateid) is done when using List Templates. When you are attaching to an specific list based on a list type that is not unique you generally use the object model. By using TemplateTypeID='104', for example, would associate with all lists with that template type.
Using the object model allows you to identify a specific instance so you can simply creates the association. So if you wanted to deploy an event receiver as a feature, you would have a feature that loads the assembly and a feature receiver code that would create the association for you via the object model.
Hopefully this makes sense.