简体   繁体   English

SPListItem 属性为 Sharepoint 返回错误的 URL 博客文章和公告

[英]SPListItem Properties returning wrong URL for Sharepoint Blog Posts and Announcements

I am writing an application that integrates select Sharepoint list items into an Activity Stream.我正在编写一个将 select Sharepoint 列表项集成到活动 Stream 中的应用程序。 I'm using Sharepoint 2010 and the new Event Receiver solution in Visual Studio.我在 Visual Studio 中使用 Sharepoint 2010 和新的事件接收器解决方案。

The problem is that I want to be able to link back to the original items in my client's Sharepoint site, and the URLs that I get for Blog Post and Announcement list items using the SPListItem.Url property don't work.问题是我希望能够链接回我客户的 Sharepoint 站点中的原始项目,并且我使用 SPListItem.Url 属性获得的博客文章和公告列表项目的 URL 不起作用。

For example, if my Blog Post is ListItemID #12, the Url that I get from SPListItem.Url is something like:例如,如果我的博客文章是 ListItemID #12,那么我从 SPListItem.Url 获得的 Url 类似于:

*Lists/Posts/12_000* *列表/帖子/12_000*

when what I need to actually navigate to the item is:当我需要实际导航到该项目时:

Lists/Posts/Post.aspx?ID=12列表/帖子/Post.aspx?ID=12

I can, of course, build the URLs myself by taking the List Url and adding '/Post.aspx.ID=' + the ItemID, but in the event a client has modified the out-of-the-box Blog Template and renamed the Post.aspx page the link would fail.当然,我可以通过获取列表 Url 并添加 '/Post.aspx.ID=' + ItemID 自己构建 URL,但如果客户修改了开箱即用的博客模板并重命名Post.aspx 页面的链接将失败。 Is there a property I'm not aware of that calls the Urls I need?是否有我不知道的属性调用我需要的 Urls?

The same issue applies to Announcements, where getting the Url has become even more complicated in Sharepoint 2010 since they now seem to open in a javascript pop-up.同样的问题适用于公告,在 Sharepoint 2010 中获取 Url 变得更加复杂,因为它们现在似乎在 javascript 弹出窗口中打开。

I had the same issue and I have resolved it by using我有同样的问题,我已经通过使用解决了

listItem.ParentList.DefaultDisplayFormUrl + ?ID=listItem.ID 

to get the post url.获取帖子 url。 Seems to resolved it back to Lists/Post/Post.aspx?ID=xxx .似乎将其解决回Lists/Post/Post.aspx?ID=xxx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM