无法更新 SharePoint 发布页面图像
Cannot Update SharePoint Publishing Page Image
我正在尝试更新发布页面图像 url 但在执行查询命令后不知何故。它的值保存为 null
ClientContext targetContext = new ClientContext ("REAL URL");
Microsoft.SharePoint.Client.File targetFile = targetContext.Web.GetFileByServerRelativeUrl ("REAL URL");
var targetPublishingPage = PublishingPage.GetPublishingPage (targetContext, targetFile.ListItemAllFields);
targetContext.Load (targetPublishingPage.ListItem);
targetContext.ExecuteQuery ();
targetFile.CheckOut ();
targetPublishingPage.ListItem["PublishingPageImage"] = "REAL URL";
targetPublishingPage.ListItem.Update ();
targetContext.ExecuteQuery ();
发布图像字段值应按以下格式指定:<img src='{imageurl}'>
例子
using (var ctx = new ClientContext(webUri))
{
var pageFile = ctx.Web.GetFileByServerRelativeUrl(pageUrl);
var pageItem = pageFile.ListItemAllFields;
pageItem["PublishingPageImage"] = "<img src='/PublishingImages/PageLogo.png'>";
pageItem.Update();
ctx.ExecuteQuery();
}
我正在尝试更新发布页面图像 url 但在执行查询命令后不知何故。它的值保存为 null
ClientContext targetContext = new ClientContext ("REAL URL");
Microsoft.SharePoint.Client.File targetFile = targetContext.Web.GetFileByServerRelativeUrl ("REAL URL");
var targetPublishingPage = PublishingPage.GetPublishingPage (targetContext, targetFile.ListItemAllFields);
targetContext.Load (targetPublishingPage.ListItem);
targetContext.ExecuteQuery ();
targetFile.CheckOut ();
targetPublishingPage.ListItem["PublishingPageImage"] = "REAL URL";
targetPublishingPage.ListItem.Update ();
targetContext.ExecuteQuery ();
发布图像字段值应按以下格式指定:<img src='{imageurl}'>
例子
using (var ctx = new ClientContext(webUri))
{
var pageFile = ctx.Web.GetFileByServerRelativeUrl(pageUrl);
var pageItem = pageFile.ListItemAllFields;
pageItem["PublishingPageImage"] = "<img src='/PublishingImages/PageLogo.png'>";
pageItem.Update();
ctx.ExecuteQuery();
}