This article Article This section describes how to create an event handle application.
I,CodeCreation
1. Create a class library (classlibrary) in)
2. Add a reference to Microsoft. Sharepoint. dll. The new class inherits Microsoft. Sharepoint. spitemeventreceiver. Using System;
Using System. Collections. Generic;
Using System. text;
Using Microsoft. SharePoint;
Namespace Simpleeventhandler
{
Public ClassSimpleeventhandler: spitemeventreceiver{
}
}
3. You can rewrite the following methods to process your events.
Itemattachmentdeleting
Itemcheckedin
Itemcheckedout
Itemcheckingin
Itemcheckingout
Itemdeleted
Itemdeleting
Itemfileconverted
Itemfilemoved
Itemfilemoving
Itemuncheckedout
Itemuncheckingout
Itemupdated
Itemupdating
In this example, we will rewriteItemupdating andItemadded The code for these two events is as follows:
Public Override Void Itemupdating (spitemeventproperties properties)
{
Properties. Cancel= True;
Properties. errormessage= "Updating is not supported.";
}
Public Override Void Itemadded (spitemeventproperties properties)
{
Properties. afterproperties ["Body"]= "Body text maintained by the system.";
}
II. Application
1. Enable event handle
Go to "Management Center"-"application"ProgramManage-SharePoint Web Application Management-General Web application settings, find backward compatible event handlers, and set to enable ".
2. Edit the project or website created by your vs. Remember to compile it into a strongly-named assembly and deploy it in the bin directory of your WSS website. Of course, it can also be deployed in GAC.
3. Select "Advanced Settings" in the document library settings for event processing on the WSS website, and in the "backward compatible event handler" item"Assembly Name:"Joe. eventhandler. demo, version = 1.0.0.0, culture = neutral, publickeytoken = 0172133e8127fd96, where Joe. eventhandler. demo is the namespace, version is the version number, and publickeytoken can be seen in GAC,"Class Name: "fill in the namespace and Class Name: Joe. eventhandler. Demo. documenthandler, and then click OK.
4. Go to the corresponding document library to test your application.