4

Okay, this seems like a pretty simple thing to do. But I'm trying to use the Sitefinity 4 Fluent API to query for a page and populate the Text/NavigationUrl properties of a HyperLink. The text gets populated fine - but it has a hard time getting the Url from the page.

        PageNode page = App.WorkWith().Page(PageId).Get();
        PageLink.Text = page.Title;
        PageLink.NavigateUrl = page.Urls.Where<PageUrlData>(pU => pU.RedirectToDefault == false).FirstOrDefault<PageUrlData>().Url;

The first and second line work fine (PageLink.Text shows the page title). On the third line, I get an "Object reference not set to an instance of an object." error... FYI PageId is a Guid reference to a page.

Any help would be greatly appreciated.

Avisra
  • 740
  • 5
  • 14

1 Answers1

8

Found the issue. PageNode requires "Telerik.Sitefinity.Pages.Model" as a reference. I had that, but later found that you ALSO need to include "Telerik.Sitefinity.Modules.Pages".

This adds a new method to my belt which I've used below (getFullUrl):

    PageNode page = App.WorkWith().Page(PageId).Get();
    PageLink.Text = page.Title;
    PageLink.NavigateUrl = page.GetFullUrl();

Thanks

Avisra
  • 740
  • 5
  • 14
  • 2
    For anyone interested in using this implementation, I've posted all of my controls here: http://www.avisra.com/blog/2011/05/22/sitefinity-control-designer-fields/ – Avisra May 22 '11 at 15:59
  • what a great resource, thanks for sharing these controls with the community! – SelAromDotNet May 23 '11 at 14:53