This section describes how to develop and register a list entry event handler. This event handler scenario: adds an information item to the "employee information" list. If the "name" is blank, the addition is canceled, if a notification is added to the "Notification" List of the website. We will overload the itemadding and itemadded methods of the spitemeventreceive receiving class, and use the object model to register the event handler.
(1) Develop an event processing assembly
Create a class project demoinfoeventhandler in Visual Studio 2005, modify the class1.cs file name to demohandler, add a reference to Microsoft. Sharepoint. dll, and add a signature to the project. The demohandler. CS code is as follows:
Compile the project and drag demoinfoeventhandler. DLL to the C: "Windows" assembly directory.
(2) register the event handler
Create a console program registereventhandler, add a reference to microsfot. javaspoit. dll, and write the following code in the main method of program. CS:
In this way, the event handler in the "employee information" list is registered, and you can test the event handler on the website.
Source code: eventhandler
"This article is the result of my work. If you have reprinted it, please indicate the source! Thank you for your cooperation ."