Find the content inside a PageNode

Posted by Community Admin on 03-Aug-2018 16:52

Find the content inside a PageNode

All Replies

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

Hello,
I've got a pageNode found using

IQueryable<PageNode> page = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend).Where(o1=>o1.Title == "DetailPage").Get();

How Do I get the News and the DownloadList item I got inside?

Ho do I bind an IQueryable<NewsItem> to the News object?
Thanks

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

Hello,
sorry, but we need this information as soon as possible, cause we have to give the demo to the customer on monday..
any suggestion please?

Thanks a lot
Ilaria

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

Hello,
I've done some success but not much ....... I've got the controls in this way :

 

IQueryable<PageNode> page = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend).Where(o1=>o1.Title == "DetailPage").Get();
         PageNode pageNode = page.FirstOrDefault();
 
         PageData pageData = pageNode.Page;
 
         var newsViewUserControl = pageData.Controls.Where(o1 => o1.ObjectType == STR_NEWS_TYPE).FirstOrDefault();
         var downloadViewUserControl = pageData.Controls.Where(o1 => o1.ObjectType == STR_DOC_TYPE).FirstOrDefault();

now I wish to set the "DataSource" of those this two items with the data I got querying the news /document using
App.WorkWith().NewsItems().Get();

with some where function.......
Thanks

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

Hello Paolo,

Actually there is no direct way to get the control on a page. Here are two options

var pageManager = PageManager.GetManager();
var page = pageManager.GetPageNodes().Where(p => p.Page.Title == "MyNewsPage").SingleOrDefault();
if(page.Page.Controls.Count > 0)
    foreach(ControlData ctrl inpage.Page.Controls)
    
        if(ctrl.Caption == "NewsView")
        
        
        
    

2. The second option is using Page.Controls collection and find the control recursively.

Greetings,
Ivan Dimitrov
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

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

Hello Ivan,
I'm on getting the control of a page..... now I still need your help on assign the control "datasource" with the news I got using FluentAPI

Thanks!
Paolo

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

Hello Paolo,

Actually you can try the code snippets I send you which can be used to set some properties at runtime. The better option would be to loop through the Page.Controls collection where you can get the instance of controls added to the page

Best wishes,
Ivan Dimitrov
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

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

I've understood this Ivan, but taking as good I've got my NewsItem control....... how do I tell him take the items I've got in mine IList<NewsItem> and bind them as datasource?

Thanks

This thread is closed