捕获 SPWeb 上的标题更改事件

发布于 2024-07-17 01:47:56 字数 259 浏览 4 评论 0原文

我正在使用 SPWebEventReceiver 监听特定的 SPWeb,该 SPWebEventReceiver 在 WebMoved 事件上成功触发。 当网络移动时,我会使用新的位置/标题更新列表。

我希望能够做的是在网络重命名时监听。 我是否可以通过附加项目侦听器并等待 ItemUpdated 事件来执行此操作? 如果是这样,我将不胜感激一小段代码! 谢谢!

I am listening on a particular SPWeb using an SPWebEventReceiver that is successfully firing on the WebMoved event. When the web is moved I update a list with the new location/title.

What I would like to be able to do is listen for when the Web is renamed . Do I do this by attaching an item listener and waiting for an ItemUpdated event? If so I would appreciate a little snippet of code! Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

烂柯人 2024-07-24 01:47:56

看起来这是 SharePoint OM 的一个错误。 事件接收器显然应该触发当网站的名称更改时,但它不会。它仅在网站的 URL 更改时触发。

It looks like this is a bug with the SharePoint OM. The event receiver is clearly supposed to fire when the name of a web is changed, but it does not. It only fires when the Web's URL is changed.

染墨丶若流云 2024-07-24 01:47:56

史蒂夫,
据我所知,SPWebEventReceiver 仅在 SPWeb 上公开以下事件(http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spwebeventreceiver_members.aspx)

  • SiteDeleted
  • SiteDeleting
  • WebDeleted
  • WedDeleting
  • WebMoved
  • WebMoving

ItemAdded 在 SPItemEventReceiver 中定义,适用于 SPListItem 对象。

SPWeb 的 Title 属性存储在属性包中 (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.properties.aspx)。

当在属性包上调用 .Update() 时(例如,更新标题时),您似乎无法访问任何事件。

Steve,
As far as I can see, SPWebEventReceiver only exposes the following events on an SPWeb (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spwebeventreceiver_members.aspx)

  • SiteDeleted
  • SiteDeleting
  • WebDeleted
  • WedDeleting
  • WebMoved
  • WebMoving

ItemAdded is defined in SPItemEventReceiver which is applicable to SPListItem objects.

The Title property of an SPWeb is stored in a property bag (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.properties.aspx).

It doesn't appear like you can tap into any events when .Update() is called on the property bag, e.g. when Title is updated.

淡紫姑娘! 2024-07-24 01:47:56
  1. 我想说,Web 名称的重命名应该会触发 WebMoved。
  2. 站点标题重命名不会触发任何操作。

问题:您希望进行哪些更改? 因为任何元数据都可以存储在内部列表中,这支持很多事件。

  1. I would say that a rename of the Web name should trigger WebMoved.
  2. Site title rename triggers no action.

Question: What changes do you want tot tap in? Because any metadata for instance could be stored in lists inside, which supports lots of events.

稚然 2024-07-24 01:47:56

我不相信这是一个错误,我相信这只是对文档的误解。 正如您所说,文档表明 WebMoving 和 WebMoved 事件是由站点的 URL 被修改或重命名而触发的:

来自 MSDN 文档:“在现有网站被重命名或移动到其他父对象之前发生的同步Before 事件。 ”

然而,用户界面中发生变化的不是网站的“名称”,而是网站的标题。 SPWeb 对象确实有一个可通过对象模型访问的“Name”属性,更新该 Name 属性并调用 SPWeb.Update() 实际上会触发 WebMoved 事件。 问题在于该属性不会通过网站的基于 Web 的设置页面公开,仅公开“标题”字段,并且此字段更改不会触发事件。 虽然这看起来有点违反直觉,甚至具有误导性,但如果您逐字阅读文档,它的行为与文档完全相同。

I don't believe it is a bug, I believe it is simply a misinterpretation of the documentation. As you have stated, the documentation indicates that the WebMoving and WebMoved events are triggered by the site's url being modified or being renamed:

from MSDN Doc: "Synchronous Before event that occurs before an existing Web site has been renamed or moved to a different parent object."

However, what gets changed in the UI is NOT the "name" of the site, but the site's title. The SPWeb object does have a "Name" property that is accessible through the Object Model, and updating that Name property and calling SPWeb.Update() does in fact trigger the WebMoved event. The trouble is that this property is not exposed through the web-based settings page for the site, only the "Title" field is exposed, and this field change does not trigger the event. While this seems a bit counter-intuitive and even misleading, if you read the documentation literally, it is behaving exactly as documented.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文