工作需要,有時候會測試各種情況下Event Handler,包括測試哪種事件是最合適的,但是每次寫Event Handler的Feature的確是重複性麻煩的事情。所以就寫了個代碼產生的小程式產生了下面的37個工程,對應37個不同的List模板。ListTemplateId來自於http://msdn.microsoft.com/en-us/library/ms431081.aspx。
工程註冊了所有的List和ListItem事件。參考:SPItemEventReceiver Methods (Microsoft.SharePoint)和
SPListEventReceiver Methods (Microsoft.SharePoint)
工程基於WSPBuilder (SharePoint WSP tool), 所以使用這個工程前請自行下載並熟悉其用法。
:LambertQin.Samples.EventHandlers.zip
更多的關於Event Handlers的文章,可以參考以下連結:
- Event Handlers (Also Known as Event Receivers) (http://msdn.microsoft.com/en-us/library/cc537498.aspx#MOSSIntroToNet_ComponentsEventHandlers)
- Event Fundamentals (http://msdn.microsoft.com/en-us/library/ms442323.aspx)
- Event Handlers (http://www.microsoft.com/winme/0901/34867/mod7/index.html)
- How to: Create an Event Handler Feature (http://msdn.microsoft.com/en-us/library/ms453149.aspx)
- Creating and Using Event Handlers in Windows SharePoint Services V3 (http://channel9.msdn.com/shows/In+the+Office/Creating-and-Using-Event-Handlers-in-Windows-SharePoint-Services-V3/)
- Building List Definitions with Event Receiver in Windows SharePoint Services 3.0 (http://msdn.microsoft.com/en-us/library/bb736146.aspx)