Attach Event Receiver to specific list

Usually you attach a event receiver to a list template, site,.. This example shows how to attach an event receiver to a specific list.

I’ve created a new event receiver that will be attached on a document library, and I’ve chosen that the event “An item adding” should be handled.
image

Now create a new SPWeb Feature with a event receiver and add following code in the method FeatureActivated.
image

Also take the pre-caution to remove the event receiver from the list in the method FeatureDeactivating.
image

The className should be retreived from the xml of the event receiver. You can find it under the tag <Class>.
image

Now deploy and activate the web feature. That should do the trick.

Reacties

Populaire posts