我正在尝试更新发布页面图像网址但不知何故执行查询命令后。其值保存为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 ();
答案 0 :(得分:2)
发布图像字段值应按以下格式指定:<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();
}