Adding controls to pages using the APIs

Posted by Community Admin on 03-Aug-2018 23:41

Adding controls to pages using the APIs

All Replies

Posted by Community Admin on 09-Aug-2010 00:00

Running the following code succeeds and I could see in the debugger that the page, literal, pagedraft are all well.

Only problem is that the Page never gets the literal when I check the page out in the Sitefinity Admin

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


Cheers

Posted by Community Admin on 11-Aug-2010 00:00

Hello Lino,

Thanks for reporting this. We will soon update the developers manual with a working example. 

All the best,
Georgi
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed