Hi All,

I am trying to create dynamic page with content in content block. Page created with selected template however content block is not properly created even content block not displays title "Content Block" when edit that page. 

When browsing that page in browser it not display any content on the page. Kindly review below code which I used to create page with content.

PageManager manager = PageManager.GetManager();

if (parentPageNodeId == Guid.Empty)
{
parentPageNodeId = SiteInitializer.CurrentFrontendRootNodeId;
}

PageNode parent = manager.GetPageNode(parentPageNodeId);
var pageId = Guid.NewGuid();

PageNode pageNode = manager.CreatePage(parent, pageId, Telerik.Sitefinity.Pages.Model.NodeType.Standard);

PageData pageData = pageNode.GetPageData();
pageData.Culture = Thread.CurrentThread.CurrentCulture.ToString();
pageData.HtmlTitle = pageDetail.Title;

pageNode.Name = pageDetail.Title;
pageNode.Description = pageDetail.Title;
pageNode.Title = pageDetail.Title;
pageNode.UrlName = Regex.Replace(pageDetail.Title.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
pageNode.ShowInNavigation = true;
pageNode.DateCreated = DateTime.UtcNow;
pageNode.LastModified = DateTime.UtcNow;
pageNode.ApprovalWorkflowState = "Published";

if (pageDetail.Title.ToLower() == "home")
{
SystemManager.CurrentContext.CurrentSite.SetHomePage(pageId);
}

manager.SaveChanges();
manager.Provider.SuppressSecurityChecks = true;

// Set Page template
PageTemplate template2 = manager.GetTemplates().Where(a => a.Name == "OneColumnHeaderFooter").FirstOrDefault();
var pageDataId = manager.GetPageNode(pageId).PageId;
var page = manager.EditPage(pageDataId, CultureInfo.CurrentUICulture);
page.TemplateId = template2.Id;
manager.PagesLifecycle.CheckIn(page);
manager.PublishPageDraft(page, CultureInfo.CurrentUICulture);
manager.SaveChanges();

// Create content Block with content 
ContentBlock cManager = new ContentBlock();
cManager.Html = pageDetail.Content;
cManager.IsShared = false;
cManager.Enabled = true;
cManager.Visible = true;
cManager.ID = "D002";

App.WorkWith().Page(pageNode.Id).AsStandardPage()
.CheckOut()
//.SetTemplateTo(templateId)
.Control()
.CreateNew(cManager, "Content")
.Do(c =>
{
c.PlaceHolder = GetContentPlaceholderId(template2.Id, "Content", 0);
c.SiblingId = GetLastControlInPlaceHolderInPageId(pageNode.Id, c.PlaceHolder);
})
.SaveChanges()
.Done()
.CheckIn()
.Publish()
.SaveChanges();

Kindly review above code and let me know what I am missing.

Thanks for your help.