November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi,
It looks like your Content Area is null?
Could you add the following line:
writableClonePage.ContentArea = new ContentArea();
Also, where did you get this code sample from? You shouldn't set:
ContentGuid = Guid.NewGuid()
/Jake
Hi, most probably the solution is what Jake suggested you in his comments. I did the same mistake to not initialize the content area type property. Before adding items into that, you can check if the content area is null then initialize it, otherwise you can just add items.
Please let us know if that not fixes your issue.
Hi Team,
I was trying to add the blocks to the ContentArea programmatically and used the following code.
DisplayOption threw an exception of type 'System.NotImplementedException'
//Save the page
contentRepository.Save(myPage, EPiServer.DataAccess.SaveAction.Publish,EPiServer.Security.AccessLevel.Read);
//Save the Block
ContentAssetHelper contentAssetFolder = ServiceLocator.Current.GetInstance<ContentAssetHelper>();
var contentAsset = contentAssetFolder.GetOrCreateAssetFolder(myPage.ContentLink);
var newBlock = contentRepository.GetDefault<RawHTML>(parentLink: contentAsset.ContentLink);
var writableClonePage = (InnerPage)myPage.CreateWritableClone();
var rep = ServiceLocator.Current.GetInstance<IContentRepository>();
newBlock.HTMLContent = new XhtmlString(WebUtility.HtmlDecode(c.Content));
IContent icontentBlock = (IContent)newBlock;
icontentBlock.Name = c.PaneName;
ContentReference savedReference = rep.Save(icontentBlock, SaveAction.Publish, AccessLevel.NoAccess);
//Add the Block to ContentArea
var AddblockItem = new ContentAreaItem
{
ContentGuid = Guid.NewGuid(),
ContentLink = savedReference
};
writableClonePage.ContentArea.Items.Add(AddblockItem);
rep.Save((IContent)writableClonePage, SaveAction.Publish, AccessLevel.Read);
Can you please help me where I made a mistake?
Thanks
Ashley
I am getting error((DisplayOption threw an exception of type 'System.NotImplementedException')) on this below line.
writableClonePage.ContentArea.Items.Add(AddblockItem);
Thanks
Ashley