Try Now
More in this section

Forums / Developing with Sitefinity / Find all instances of Shared Content

Find all instances of Shared Content

2 posts, 0 answered
  1. Bart Welch
    Bart Welch avatar
    64 posts
    10 Jul 2009
    08 Dec 2009
    Link to this post
    How can I easily find all instances where a piece of shared content is used?  Example.  I have shared content called ABC.  How can I find all of the pages that show content ABC?

    Also, is there a way to find the name of a piece of shared content when you edit that item directly from the page?  Just in case we cannot find it by searching in the modules.

    Thank you

  2. Georgi
    Georgi avatar
    3583 posts
    28 Oct 2016
    09 Dec 2009
    Link to this post
    Hello Bart Welch,

    You cannot do it through the user interface, but can use the following code:

    using Telerik.Cms;
    using System.Collections;
    using Telerik.Cms.Engine;
    public partial class UserControls_WebUserControl : System.Web.UI.UserControl
        protected void Page_Load(object sender, EventArgs e)
            CmsManager manager = new CmsManager();
            // Get all GenericContent controls in a list
            IList pages = manager.GetPages();
            foreach (IPage page in pages)
                foreach (WebControl control in page.Controls)
                    if (control.GetType() == (typeof(Telerik.Cms.Engine.WebControls.GenericContent)))
                        Telerik.Cms.Engine.WebControls.GenericContent webControlGC = control as Telerik.Cms.Engine.WebControls.GenericContent;
                        if (webControlGC != null)
                            //The Generic Content ID of the content showed in this control is:
                            Guid contentID = webControlGC.ContentID;
                            ContentManager cntManager = new ContentManager("Generic_Content");
                            IContent contentItem = cntManager.GetContent(contentID);
                            if (contentItem.Content == "ABC")
                                Response.Write(String.Format("Content is on page {0}, and its id is {1}<br />", page.Name, contentID));

    I hope this helps. 

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered