More in this section

Forums / Developing with Sitefinity / How to identify the Shared Content that a Generic Content control is using

How to identify the Shared Content that a Generic Content control is using

2 posts, 0 answered
  1. ddblee
    ddblee avatar
    20 posts
    24 Jul 2008
    02 Apr 2009
    Link to this post
    We have a site that has hundreds of pages, many of which use the generic content control to display Shared Content items.

    When our content editors work with these pages in the Admin section, it is very difficult for them to determine which Shared Content item any given Generic Content control is linked to. All that the editor does is display some text that says, "This content is shared. Any changes made to it will affect all other Generic Content controls linked to it."

    Is there a way to display the name of the shared content item above or below this warning message?

  2. Georgi
    Georgi avatar
    3583 posts
    28 Oct 2016
    03 Apr 2009
    Link to this post

    You could try to extend the Generic Content control and the functionality you need. Please take a look at the KB Article How to wrap or extend Generic Content control

    Here is the code that will help you to find all controls on all pages, using the ContentID (shared content) from your base control:
    using Telerik.Cms; 
    using System.Collections; 
    using Telerik.Cms.Engine.WebControls; 
    private void FindSharedGC() 
        CmsManager manager = new CmsManager(); 
        // Get all pages 
        IList pages = manager.GetPages(); 
        foreach (IPage page in pages) 
            foreach (ICmsWebControl control in page.Controls) 
                if (control.TypeName.Equals(typeof(Telerik.Cms.Engine.WebControls.GenericContent).FullName)) 
                    //we have a Generic content control so far 
                    GenericContent webControl = control.LoadControl(thisas GenericContent; 
                    if (webControl.ContentID != null && base.ContentID) 
                        Response.Write("There is a shared content on " + page.Name + " using this shared content"); 

    I hope this will help you to get started.

    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
2 posts, 0 answered