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 ();
}
}