PageNode returns nothing

Posted by Community Admin on 03-Aug-2018 08:54

PageNode returns nothing

All Replies

Posted by Community Admin on 14-Jul-2011 00:00

Hello,

I am developing an application with Sitefinity 4.1 SP2. There is a scenario where I have to get Page Details so i m using GetPAgeNodes() method of PageNode class with below code

PageNode pga = pageManager.GetPageNodes().Where(pD => pD.Title == currentAccessedPage).FirstOrDefault();

But the above code returns NULL. I have tried with UrlName, Title and other varous ways but no luck. Nothing returns. Have gone through the existing threads of Sitefinity forum. Above method was mentioned most of time in your forums. I have also tried with fluent API, it does not return anything.

Please help me out in this situation and how to get page details as we need to have PageId of requested Page so that we can have information for assigned permissions and Roles.
Waiting for your response as early as possible

Thanks
Fareed Khan

Posted by Community Admin on 19-Jul-2011 00:00

Hi Fareed,

Please take a look at the below examples showing how you can properly access the page details using Fluent API.

var fluent = App.WorkWith().Pages();
            //get a page by its Title
            var mypage = fluent.LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
                                     .Where(p => p.Page.Title == "Test").Get().FirstOrDefault();
 
            //get the id of that page
            var pageId = mypage.Id;
            //get a list of pageNodes
            var pageNodes = App.WorkWith().Pages().Get().ToList();
            foreach (var p in pageNodes)
            
                //get the node id
                var nodeId = p.Id;
                //get the id of the page in that node
                var myPageId = p.Page.Id;
                //get the page UrlName
                var myPageUrlName = p.Page.UrlName;
                //etc..
            
when working with PageData in a PageNode it's good to check if  p.Page is not NULL, since group pages for instance do not have PageData object, and your code will return Null exception. Please do not hesitate to write back if you have any additional questions

Greetings,
Boyan Barnev
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

This thread is closed