1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Dynamically Create Page With Content Items

Dynamically Create Page With Content Items

2 posts, 0 answered
  1. Steve Jones
    Steve  Jones avatar
    8 posts
    Registered:
    07 Dec 2007
    11 Jun 2011
    Link to this post
    Hello,

    I am new Sitefinity development. I have database bound RadTreeView Control that I added to my Sitefinity Toolbox. I am looking to accomplish the following

    When an item on the tree is clicked, I would like the current page to refresh with new content. The new content on the page will come from a single content block item. So essentially I am looking to dynamically create a page by adding a content block item to the page. This dynamically created page should use the default template. How can I do this?

    For the above to work, I need to create an association between a tree item and content block item, how can I do this? 

    Also, is there a way to insert hyper-links to other content block items (NOT pages), in a content block item. So when a link on content block item is clicked, the page reloads with the new content, and using the default page template?

    A code sample would really help on the above, if thats possible.

    Waiting anxiously for assistance on the above, thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Jun 2011
    Link to this post
    Hi Steve,

    1. Here is a sample that shows how to add control on a page

    var pagemanager = PageManager.GetManager();
    var cntrl = pagemanager.CreateControl<PageControl>();
    cntrl.ObjectType = typeof(ContentBlock).FullName;
    cntrl.PlaceHolder = "Header";
    cntrl.Caption = "test";
    cntrl.Description = "dasdasda";
    var page = pagemanager.GetPageNodes().First();
    page.Page.Controls.Add(cntrl);
    pagemanager.SaveChanges()

    2. You can use attributes, value or text properties of the RadTreeNode to make the association with the content item.

    Note that if you want persist the controls and the value you set for some properties, this will make database transactions and if there are many users on the website this will cause performance issues.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered