Relationship between the controls and the pages

Posted by Community Admin on 04-Aug-2018 13:21

Relationship between the controls and the pages

All Replies

Posted by Community Admin on 09-Sep-2011 00:00
I need to know how to find the contents  (ContentBlock, ContentImage). I need to get back the reference of these contents that are in one page from another one.

How can I get the HTML from those controls that are associated to a page?

Which is the table in the DB that have the relationship between the controls and the pages?

Thanks in advance!

Fernando Basaez.
Posted by Community Admin on 14-Sep-2011 00:00
Hello Fernando,

 You can use our Fluent Api to get the PageNode of the specific page and then select the control that you wish from that page. Here's a sample code that gets the html from a ContentBlock control on a page with Title "PageTitle" does this:

PageNode node = App.WorkWith().Pages().Where(p => p.Title == "PageTitle").Get().First();
 var control = node.Page.Controls.Where(c => c.GetType().Name == "ContentBlock").First();
PageManager manager = PageManager.GetManager();
ContentBlock block = manager.LoadControl(control) as ContentBlock;
var html = (control as ContentBlock).Html;
All the best,
Svetoslav Petsov
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
Posted by Community Admin on 29-Sep-2011 00:00
Svetoslav, thanks for replying. one more questioncould you give an example to get thegui of a photograph from an Image Control, I tried the same thing, but I have not worked.

thank you very much
.
Posted by Community Admin on 30-Sep-2011 00:00
Hi F_E_R_S,

 You can use this:

PageNode node = App.WorkWith().Pages().Where(p => p.Title == "Home").Get().First();
            var control = node.Page.Controls.Where(c => c.ObjectType == "Telerik.Sitefinity.Web.UI.PublicControls.ImageControl").First();
            PageManager manager = PageManager.GetManager();
            ImageControl imageControl = manager.LoadControl(control) as ImageControl;
            var imageId = imageControl.ImageId;
Regards,
Svetoslav Petsov
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