- private void DeleteEventReceiverFromAList(string siteUrl)
- {
- using (SPSite site = new SPSite(siteUrl))
- {
- using(SPWeb web = site.OpenWeb())
- {
- try
- {
- SPList list = web.Lists["myList"];
- if (list != null)
- {
- string className = "EventReceiverClass";
- string asmName = "EventReceiverAssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a865f0ecc234ea51";
- web.AllowUnsafeUpdates = true;
- int receivers = list.EventReceivers.Count;
- bool isAddedReceiverExist = false;
- bool isUpdatedReceiverExist = false;
- for (int i = 0; i <>
- {
- SPEventReceiverDefinition eventReceiver = list.EventReceivers[i];
- if (eventReceiver.Class == className && eventReceiver.Type == SPEventReceiverType.ItemAdded)
- {
- eventReceiver.Delete();
- break;
- }
- }
- }
- }
- catch { }
- finally
- {
- web.AllowUnsafeUpdates = false;
- }
- }
- }
- }
Monday, January 31, 2011
Delete event receiver from a SharePoint list
Wednesday, January 26, 2011
Sunday, January 23, 2011
Subscribe to:
Posts (Atom)