使用 MOSS 2007 Feature 操作 Event Handler
To register event handler for list events , create folder in the \template\features folder named "EventFeature" which contain a feature.xml file that specifies the scope and ID of the "feature" and element .xml file that the former file references.The feature file might look like the following :
< Feature>
< Scope="Web" Title="Event handler" Id="Create a GUID" xmlns="http://schemas.microsoft.com/sharepoint/" >
< ElementManifests >
< ElementManifest location="element.xml" >
< /ElementManifests>
< /Feature>
The element.xml file registers the event handler assembly and associates it with a list type, for announcement list type is 104 as shown below:
< Elements >
< Receiver >
< ListTemplateOwners="name of site definition using which this site is created and this list belongs to" ListTemplateId="104" >
< Receiver >
< Name >EventHandler< /Name >
< Type >2< /Type >
< SequenceNumber >10000< /SequenceNumber >
< Assembly > "NameSpace name of assembly" ,version=1.0.0.0,Culture=neutral,PublicKeyToken="public key token of assembly" < /Assembly >
< /Class >"ClassNameOfAssembly"< /Class >
< Data >< /Data >
< Filter >< /Filter >
< /Receiver >
< /Receivers >
< /Elements >
Once we are done with feature creation ,register feature using stsadm.exe tool present in "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN" Run the following command to install feature :
stsadm -o installfeature -filename EventFeature\feature.xml
Run the follwing command to activate the feature:
stsadm -o activatefeature -filename EventFeature\feature.xml -url "url of the site"