0

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

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.

https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.fields.imagefieldvalue.imageurl(v=office.14).aspx

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.