1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / PageManager.GetTemplates not working

PageManager.GetTemplates not working

6 posts, 0 answered
  1. Phil
    Phil avatar
    89 posts
    Registered:
    19 Oct 2010
    12 Nov 2010
    Link to this post
    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.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Nov 2010
    Link to this post
    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
  3. Phil
    Phil avatar
    89 posts
    Registered:
    19 Oct 2010
    15 Nov 2010
    Link to this post
    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.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    15 Nov 2010
    Link to this post
    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
  5. Phil
    Phil avatar
    89 posts
    Registered:
    19 Oct 2010
    18 Nov 2010
    Link to this post
    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.
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    18 Nov 2010
    Link to this post
    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
6 posts, 0 answered