Querying for Page by Name

Posted by Community Admin on 03-Aug-2018 18:47

Querying for Page by Name

All Replies

Posted by Community Admin on 24-Jan-2011 00:00

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
....

Posted by Community Admin on 25-Jan-2011 00:00

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

This thread is closed