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

contentblock

2 posts, 0 answered
  1. Annie
    Annie avatar
    46 posts
    Registered:
    11 Aug 2012
    15 Feb 2012
    Link to this post
    Hi,

    I have the following code, that I am using to find contenblocks in a page. But I am not sure how to get the content from the contentblock.

     PageManager pageManager = PageManager.GetManager();
     IQueryable<PageData> pages = pageManager.GetPageDataList();
     foreach (PageData page in pages)
      {
                foreach (var c in page.Controls)
                {
                    var ctrl = pageManager.LoadControl(c);
                    if (ctrl is ContentBlock)
                    {
                        //get content
                    }
                }
          }

    Thanks,
    Annie
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    16 Feb 2012
    Link to this post
    Hello Annie,

    The ContentBlock control has a property Html that you can operate with directly or use:

    var htmlProperty = item.GetProperties(culture, false).SingleOrDefault(p => p.Name == "Html";


    All the best,
    Boyan Barnev
    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