SPSite site = new SPSite("http://siteURL");
SPWeb web = site.OpenWeb("mk");
SPList list = web.Lists["TestEventListner"];
string assemblyName = "AddEvent,Version=1.0.0.0,culture=neutral,PublicKeyToken=456722d93042a39b";
string className = "AddEvent.AddUser";
list.EventReceivers.Add(SPEventReceiverType.ItemAdded, assemblyName, className);
list.EventReceivers.Add(SPEventReceiverType.ItemAdding, assemblyName, className);
list.EventReceivers.Add(SPEventReceiverType.ItemUpdated, assemblyName, className);
list.EventReceivers.Add(SPEventReceiverType.ItemUpdating, assemblyName, className);
list.EventReceivers.Add(SPEventReceiverType.ItemDeleted, assemblyName, className);
list.EventReceivers.Add(SPEventReceiverType.ItemUpdating, assemblyName, className);
list.Update(true);
No comments:
Post a Comment