Tuesday, May 4, 2010

Attach event handler in SharePoint

SPSecurity.RunWithElevatedPrivileges(delegate()
{

SPSite sps = new SPSite("http://test:1659/");
SPWeb impersonateweb = sps.OpenWeb();
impersonateweb.AllowUnsafeUpdates = true;
SPList _spListAanwezige = impersonateweb.Lists["Survey"];
_spListAanwezige.EventReceivers.Add(SPEventReceiverType.ItemAdded,
"ReplicateData, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1f0faf7eec29149f", "ReplicateData.SurveyEventHandler");
impersonateweb.AllowUnsafeUpdates = false;

});

No comments: