LB.*_*LB. 3 sharepoint content-type event-handling
我创建了一个事件接收器并添加到GAC中.
如何将事件接收器绑定到特定的自定义内容类型?
我需要从XML文件中执行此操作:
到目前为止,我有:
Feature.xml指向Elements.xml文件但不确定Elements.xml文件.
您如何引用特定的内容类型?(我有特定内容类型的指南)
若要将事件接收器绑定到特定内容类型,请使用内容类型元素文件的XmlDocuments元素.这是我即将出版的"构建SharePoint用户体验"一书中的一个相当独特的摘录:
而且,只是为了澄清,因为我没有看到你试图发布的XML,你可以将它添加到elements.xml文件中的内容类型声明中.
(......)
使用功能将事件接收器附加到内容类型
附加事件接收器就像我们刚刚看到的那样重要的是要注意,没有办法将接收器绑定到内容类型,只能绑定到列表模板.
不,没有办法将接收器添加到单个列表中.但是,正如我们在林列表森林中的电子邮件启用自定义列表部分中看到的那样,我们可以使用代码以编程方式添加事件接收器.我们可以使用相同的技术将事件接收器添加到内容类型,但应该有一种方法可以在功能中使用CAML.在我们定义内容类型的所有内容之后,我们将在本章后面看到.
答案?内容类型中的事件接收器在元素文件的不同部分中定义.我们再次查看XmlDocuments和第三个内置的XmlDocument类型Receiver.Receiver XmlDocument驻留在http://schemas.microsoft.com/sharepoint/events命名空间中.如果要在默认SharePoint安装中查看Receiver XmlDocument,请在ctypeswss.xml文件中搜索内容类型0x010107,即DocumentWorkflowItem:
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events">
<spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events">
<Receiver>
<Name>Workflow Library Item Added</Name>
<Type>ItemAdded</Type>
<SequenceNumber>1</SequenceNumber>
<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral,~CCC
PublicKeyToken=71e9bce111e9429c</Assembly>
<Class>Microsoft.SharePoint.Workflow.SPWorkflowLibraryEventReceiver</Class>
<Data />
<Filter />
</Receiver>
… (snipped for space saving purposes
</Receivers>
</XmlDocument>
Run Code Online (Sandbox Code Playgroud)
注意该示例使用前缀spe:表示Receivers元素.从技术角度来看,这不是必需的,但可以增加代码的清晰度.如您所见,Receiver元素遵循元素中定义的常规项事件接收器的结构.当然,除了接收器是在内容类型的XmlDocument部分中定义的.
| 归档时间: |
|
| 查看次数: |
9114 次 |
| 最近记录: |