More in this section

Forums / Developing with Sitefinity / Accessing generic content for page

Accessing generic content for page

2 posts, 0 answered
  1. Annie
    Annie avatar
    123 posts
    08 Apr 2009
    29 Oct 2010
    Link to this post

    How can programmatically access a generic content that is on a particular page?

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    31 Oct 2010
    Link to this post
    Hello Annie,

    Below is a sample code that illustrates desired behavior

    var cmsManager = new Telerik.Cms.CmsManager();
    // get your page here - currentPage
    IList<Telerik.Cms.ICmsWebControl> pageControls = currentPage.Staged.Controls;
    foreach (Telerik.Cms.ICmsWebControl webCtrl in pageControls)
     if (webCtrl.ContainerID == "MyContentHolder" && webCtrl.ControlType == typeof(Telerik.Cms.Engine.WebControls.GenericContent))
         var gcCtrl = webCtrl.LoadControl() as Telerik.Cms.Engine.WebControls.GenericContent;
    var content = gcCtrl.Content;

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about 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