Scenario:
You want to add an event handler from a particular item within your list/library
Pre-requisite:
You already have assembly compiled
Code:
using Microsoft.SharePoint ;Use:
SPSite site = new SPSite("http://moss");
SPWeb web = site.AllWebs["/"];
SPList list = web.Lists["List_Name"];
string assemblyName = "[full 4-part assembly name]";
string className = "Namespace.ClassName";
list.EventReceivers.Add(SPEventReceiverType.ItemAdded, assemblyName, className);
list.EventReceivers.Add(SPEventReceiverType.ItemUpdated, assemblyName, className);
list.EventReceivers.Add(SPEventReceiverType.ItemDeleting, assemblyName, className);
Console Application, At the time of Feature Activation
0 comments:
Post a Comment