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

Forums / Developing with Sitefinity / Relationship between the controls and the pages

Relationship between the controls and the pages

4 posts, 0 answered
  1. F_E_R_S
    F_E_R_S avatar
    3 posts
    Registered:
    30 Mar 2011
    09 Sep 2011
    Link to this post
    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.
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    14 Sep 2011
    Link to this post
    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
  3. F_E_R_S
    F_E_R_S avatar
    3 posts
    Registered:
    30 Mar 2011
    29 Sep 2011
    Link to this post
    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
    .
  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    30 Sep 2011
    Link to this post
    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
4 posts, 0 answered