错误截图错误日志位置:C:\ProgramFiles\CommonFiles\microsoftshared\WebServerExtensions\15\LOGS主要错误ThecurrentuserisnotanSharePointServerfarmadministrator.处理过程查看了当前User确实不是场管理员,但......
2022-04-11 67 SharePoint ERROR the current user not Server farm 错误
SPListItem的Url属性返回的不是绝对路径,形式如下面:
http://cary/Lists/Discussion/itemtitle
这种形式是不能作为链接打开的,很多时候我们在取到这个item的同时还要得到这个item的url,比如你筛选出列表中指定的数据并发邮件给相关人员的时候,在邮件的内容中就需要有个这个item的链接。
Moss中提供了一个PAGETYPE枚举,具体如下表:
名称 | 描述 |
PAGE_DEFAULTVIEW | Default view. Value=0. |
PAGE_DIALOGVIEW | File dialog box view. Value=2. |
PAGE_DISPLAYFORM | Display form for list items. Value=4. |
PAGE_DISPLAYFORMDIALOG | Display form for a file dialog box. Value=5. |
PAGE_EDITFORM | Edit form for list items. Value=6. |
PAGE_EDITFORMDIALOG | Edit form for a file dialog box. Value=7. |
PAGE_INVALID | Not used. Value= -1. |
PAGE_MAXITEMS | Not used. Value=11. |
PAGE_NEWFORM | New form for list items. Value=8. |
PAGE_NEWFORMDIALOG | New form for a file dialog box. Value=9. |
PAGE_NORMALVIEW | Normal view. Value=1. |
PAGE_SOLUTIONFORM | Solution form. Value=10. |
PAGE_VIEW | View, including both default view and normal view. Value=3. |
我们就可以通过如下代码来得到item的链接:
SPList list = site.Lists.GetList("/Lists/Discussion ");
SPListItem item = list.Items[id];
String strUrl=list.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url + "?ID=" + item.ID
利用这个可以得到下面形式链接:
http://cary/Lists/Discussion/DispForm.aspx?ID=680
这个就可以作为链接打开了.
附录:
DataTable dt = new DataTable();
dt.Columns.Add("标题");
dt.Columns.Add("路径");
SPSite site = new SPSite("http://sharepoint02:9003");
SPWeb web = site.OpenWeb();
SPList list = web.GetList("/Lists/List1");
String strUrl = "";
for (int i = 0; i < list.Items.Count; i++)
{
strUrl = list.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url + "?ID=" + list.Items[i].ID;
DataRow dr = dt.NewRow();
dr["标题"] = list.Items[i].Title;
dr["路径"] = "" + list.Items[i].Title + "";
dt.Rows.Add(dr);
}
相关文章
SharePoint2013爬网报错AnunrecognizedHTTPresponsewasreceivedwhenattemptingtocrawlthisitem.Verifywhethertheitemcanbeaccessedusingyourbrowser.然后登陆网站,发现在服务器上输入3次用户名密码白页,考虑到......
2022-04-11 449 SharePoint ERROR unrecognized HTTP response was received
最近使用SharePoint中,遇到一个需要重命名网站集的需求,主要是网站用数据库备份/还原的方式,想要改网站集的地址,然后搜了一下PowerShell:$site=Get-SPSite-Identityhttp://server/sites/Demo$site.......
2022-04-11 299 SharePoint重命名网站集名称