Remove an event handler er in SharePoint

Source: Internet
Author: User
Document directory
  • Everyone and their brother shows you the quick and dirty method on how to add an event handler er to a list. not everyone people show you how to remove them (not even some of the Microsoft Press books ...) There are 2 ways .. if you have the guid of your event aggreger, instantiate an instance of an speventreceiverdefintion object with that guid and then delete it. else, here's the long way: (I'm going under the assumption that you're a good MOSS/WSS programmer and using features to deploy your event handler ...)
Everyone and their brother shows you the quick and dirty method on how to add an event handler er to a list. not everyone people show you how to remove them (not even some of the Microsoft Press books ...) There are 2 ways .. if you have the guid of your event aggreger, instantiate an instance of an speventreceiverdefintion object with that guid and then delete it. else, here's the long way: (I'm going under the assumption that you're a good MOSS/WSS programmer and using features to deploy your event handler ...)

Public override void featuredeactivating (spfeaturereceiverproperties properties ){

Using (spweb web = (spweb) properties. feature. Parent ){

Spdocumentlibrary proposals = (spdocumentlibrary) web. Lists ["test"];
Speventreceiverdefinitioncollection erdc = proposals. eventreceivers;
Speventreceiverdefinition ERD = NULL;
Bool found = false;

For (INT I = 0; I <erdc. Count; ++ I ){
ERD = erdc [I]; If (ERD. Assembly = asmname & ERD. type = speventreceivertype. itemadded ){
Found = true;
Break ;}
} If (found)
ERD. Delete ();
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.