Monday, December 5, 2011

Deploying Event Receivers Programmatically

SPWeb webSite = new SPSite(“http://win2k3r2lab”).OpenWeb();
SPList theList = webSite.Lists[“Tasks”];
SPEventReceiverDefinition newReceiver = theList.EventReceivers.Add();
newReceiver.Class = “Receiver.ReceiverClass”;
newReceiver.Assembly =
“Receiver,Version=1.0.0.0,Culture=neutral,PublicKeyToken=abc123abc123abc”;
newReceiver.Sequence = 5000;
newReceiver.Type = SPEventReceiverType.ItemUpdated;
newReceiver.Update();

No comments:

Post a Comment