PageManager.GetTemplates not working

Posted by Community Admin on 03-Aug-2018 20:51

PageManager.GetTemplates not working

All Replies

Posted by Community Admin on 12-Nov-2010 00:00

I am using SF 4.0 Beta 2
I am trying to create a SF page programmatically.  I am running into the same problem using the SF API directly and also using the Fluent façade API:
    this code: myPageManager.GetTemplates()  returns nothing.
        - it is used in the SF API example like this
        - myPageData.Template = myPageManager.GetTemplates().First();
        - and it is used in the Fluent API example like this
        - Guid templateGuid = pManager.GetTemplates().First().Id;
        - the error and inner exception that I am getting are
            - "No items found in the sequence."
            - "Enumeration yielded no results"

Please advise.
Thank you.

Posted by Community Admin on 13-Nov-2010 00:00

Hello Phillip,

I am not able to replicate this issue. There are built-in templates loaded as embedded resources like

  • OneColumnHeaderFooter
  • LeftSidebarHeaderFooter
  • RightSidebarHeaderFooter
  • LeftSidebar
  • RightSidebar
  • TwoEqualHeaderFooter
  • ThreeEqualHeaderFooter
  • TwoSidebarsHeaderFooter
  • Promo3ColumnsHeaderFooter

Sincerely yours,
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 15-Nov-2010 00:00

Thanks Ivan.  Your "embedded resource" comment made me try something which worked.

Background: Here is how I was testing my code: It is in an ascx user control and that is in a aspx page, in Visual Studio 2010.  To test the code, I hit F5 and my aspx page opens.  I click the button to run my code and GetTemplates() fails to find an item.

Solution:  I changed the Start Options in Visual Studio so that ~/sitefinity/default.aspx (the Dashboard) opens when I hit F5.  (My theory was that this would load the templates.)  THEN I go to my MakePage.aspx page and GetTemplates() finds a template.

Question: what C# code would load the templates (and maybe other embedded resources) programatically.

Posted by Community Admin on 15-Nov-2010 00:00

Hi Phillip,

There are two methods that you can use

  • GetTemplate(Guid id) - returns PageTemplate
  • GetTemplates() - returns - IQueryable<PageTemplate>
The only reason for an empty query would be if you do not have permissions to view these templates and you use an anonymous user - you are not authenticated.
Kind regards,
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 18-Nov-2010 00:00

Thanks Ivan.  That all makes sense. I dont have the permissions I need because I am not logged in.

So what is the C# code that I can use to programatically log in?

Thanks.

Posted by Community Admin on 18-Nov-2010 00:00

Hello Phil,

You can check out this forum thread for more information on programmatic login. We are also going to provide the ability to login through a web service. But this will be available after the RC.

All the best,
Radoslav Georgiev
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