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

Forums / General Discussions / Querying for Page by Name

Querying for Page by Name

2 posts, 0 answered
  1. Dallas Beek
    Dallas Beek avatar
    10 posts
    Registered:
    19 May 2010
    24 Jan 2011
    Link to this post
    I'm a bit perflexed as to how to use the fluent api.  I have a custom control and I want to bind a hyperlink to a specific page.

    protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container) {
        HyperLink homelnk = this.Container.GetControl<HyperLink>("home", true);
        var homePage = App.WorkWith().Pages().Where(p => p.Page.Title == "Home").Get().FirstOrDefault();
        homelnk.NavigateUrl = homePage.GetUrl();
        homelnk.Text = homePage.Page.HtmlTitle;
    }

    The problem is that the homePage is always null.  When I output the entire list of pages I don't see any of my pages.  What am I doing wrong?

    Dashboard
    Pages
    FrontendSiteMap
    Users
    BackendSiteMap
    Roles
    ....
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    25 Jan 2011
    Link to this post
    Hi Dallas Beek,

    You need to modify the query for getting the PageNode:

    var homePage = App.WorkWith().Pages().Where(p => p.Title == "Home").Get().FirstOrDefault();
    if (homePage != null)
    {
        ...
    }

    For more details how to use fluent API please refer to the following documentation article: Fluent API

    Best wishes,
    Pepi
    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