I am trying to update publishing Page image URL but somehow after executing query command, its value saved as null

Below is the code that I am using to update image URL field-

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 ();

If I understand your Question

mageFieldValue pageImage = ListItem["PublishingRollupImage"] as ImageFieldValue;
                           string pageImageurl = pageImage.ImageUrl;
                           Image1.ImageUrl = pageImageurl;

you may look following link for further details.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.