More in this section

Forums / General Discussions / Getting a List of PageNodes with Specific Controls

Getting a List of PageNodes with Specific Controls

3 posts, 1 answered
  1. James
    James avatar
    19 posts
    Registered:
    21 Jan 2011
    15 Sep 2011
    Link to this post
    I was having an issue writing some lambda code to get a list of pages with a specific control object type.

    Say I am looking for the "widget" type
    MyProject.NameSpace.ControlType

    How would I write the lambda?

    var pm = PageManager.GetManager();
    var pnWithObjectType = pm.GetPageNodes()
        .Where(pn => pn.Page != null)   
        // unsure how to add this piece below
        // this does not compile
        .Where(pc => pc.Page.Controls.Where(control => control.ObjectType == "MyProject.NameSpace.ControlType"));
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    17 Sep 2011
    Link to this post
    Hi James,

     Try this:

    var pm = PageManager.GetManager();
                var pnWithObjectType = pm.GetPageNodes()
                    .Where(pn => pn.Page != null)
                    .Where(pd => pd.Page.Controls.Any(c => c.ObjectType.StartsWith(typeof(MyProject.Namespace.ControlType).FullName)));
    Best wishes,
    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
    Answered
  3. James
    James avatar
    19 posts
    Registered:
    21 Jan 2011
    19 Sep 2011
    Link to this post
    This is exactly what I needed!  Throwing it on our utility class.  Thanks so much for your help.
3 posts, 1 answered