C# 如何将事件接收器附加到 sharepoint 中的自定义列表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/924964/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to attach an event receiver to a custom list in sharepoint?
提问by raklos
What are the steps required in attaching an event receiver to a custom list in sharepoint?
将事件接收器附加到 sharepoint 中的自定义列表需要哪些步骤?
回答by Lance Perry
This can be done in at least two different ways:
这可以通过至少两种不同的方式完成:
- Create a feature that upon feature activation you have the proper code to attach to a specific list (use this URLfor some help)
- Or you could have a console application that will have code to attach to a specific list (again using the same code as in the URL mentioned above)
- 创建一个功能,在功能激活后,您可以将正确的代码附加到特定列表(使用此 URL获取帮助)
- 或者你可以有一个控制台应用程序,它将代码附加到特定列表(再次使用与上述 URL 中相同的代码)
For further help go here.
如需进一步帮助,请访问此处。
回答by Flo
There are several ways to attach EventReceivers to lists, ContentTypes or sites. Take a look at Brian Wilson's blog postabout this topic and describes several ways to do this.
有多种方法可以将 EventReceiver 附加到列表、ContentType 或站点。请查看Brian Wilson 的关于此主题的博客文章,并描述了执行此操作的几种方法。
He also developed a SharePoint Feature which deploys a configuration page where you can attach and delete EventReceivers over an UI.
他还开发了一个 SharePoint 功能,该功能部署了一个配置页面,您可以在其中通过 UI 附加和删除 EventReceiver。
回答by Ahmed MEZRI
you may go to element file and edit the tag Receivers, change the value of the attribut ListUrl to whatever is your URL for instance if your list is called Customers, insert <Receivers ListUrl="Lists/Customers">
Try this and good luck
您可以转到元素文件并编辑标签接收器,将属性 ListUrl 的值更改为您的 URL,例如,如果您的列表名为客户,请插入<Receivers ListUrl="Lists/Customers">
试试这个,祝你好运
回答by Artur
All you have to do is replace the following line in Elements.xml:
您所要做的就是替换 Elements.xml 中的以下行:
<Receivers ListTemplateId="*number*">
with
和
<Receivers ListUrl="Lists/*your list name*">
Notethat "Url" is written with only the first character capitalized
请注意,“Url”只写第一个字符大写