Adding controls to pages using the APIs
Running the following code succeeds and I could see in the debugger that the page, literal, pagedraft are all well.
public
void
insertcontentInPage()
var pManager = PageManager.GetManager();
var page = pManager.GetPageDataList().Where(t => t.HtmlTitle == "Lino testing
page").SingleOrDefault();
PageDraft editPage = pManager.EditPage(page.Id,
false
);
Literal simpleText =
new
Literal();
simpleText.Text =
"This is a simple control, added to a page."
;
PageDraftControl draftControl =
pManager.CreateControl<PageDraftControl>(simpleText,
"Header"
);
editPage.Controls.Add(draftControl);
pManager.PublishPageDraft(editPage.Id,
true
);
pManager.SaveChanges();
SiteMapBase.Cache.Flush();
Hello Lino,
Thanks for reporting this. We will soon update the developers manual with a working example.
All the best,