Dynamically Create Page With Content Items

Posted by Community Admin on 04-Aug-2018 01:17

Dynamically Create Page With Content Items

All Replies

Posted by Community Admin on 11-Jun-2011 00:00

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

Posted by Community Admin on 13-Jun-2011 00:00

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

This thread is closed