SharePoint中的EventReceiver 之四 为Content Type编写Event Handler

在前面的部分, 我们创建了CompanyItemEventReceiver类来在Company names中使用大写来保持数据完整性. 作为这个Event Receiver的系列的最后部分, 我们现在希望展现一下如何把event receiver类中的event handler绑定到Company这个Content Types上. 这是通过在content type的definition中使用一个inner XmlDocument节点, 下面进行了举例. 你可以看到, 每一个event handler都必须被单独地使用相同地信息来绑定.

 

<ContentType ID="0x0100E71A2716C18B4e96A9B0461156806FFA" Name="Company" >
  <!-- FieldRefs element omitted for clarity -->
  <!-- event handlers added to content type using XmlDocument element -->
  <XmlDocuments>
    <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events">
      <spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events">
        <spe:Receiver>
          <spe:Name>ItemAddedReceiver</spe:Name>
          <spe:Type>ItemAdded</spe:Type>
          <spe:Assembly>LitwareTypes, [full 4-part assembly name] </spe:Assembly>
          <spe:Class>LitwareTypes.CompanyItemEventReceiver</spe:Class>
        </spe:Receiver>
        <spe:Receiver>
          <spe:Name>ItemUpdatedReceiver</spe:Name>
          <spe:Type>ItemUpdated</spe:Type>
          <spe:Assembly>LitwareTypes, [full 4-part assembly name] </spe:Assembly>
          <spe:Class>LitwareTypes.CompanyItemEventReceiver</spe:Class>
        </spe:Receiver>
      </spe:Receivers>
    </XmlDocument>
  </XmlDocuments>
</ContentType>

 

译自:

Inside Microsoft Windows SharePoint Services 3.0

posted on 2010-02-07 13:52  中道学友  阅读(706)  评论(0编辑  收藏  举报

导航

技术追求准确,态度积极向上