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

Forums / Sitefinity SDK / LayoutTemplatePath

LayoutTemplatePath

6 posts, 0 answered
  1. Joe Keller
    Joe Keller avatar
    48 posts
    Registered:
    07 Apr 2010
    15 Sep 2010
    Link to this post
    I have implemented the Jobs module in the samples in the SDK, it embeds the templates as a resource in the library.
    I was wondering if someone could give me an example of how I would go about using LayoutTemplatePath to reference an .ascx file that is part of the website's filesystem instead of the embedded resources.

    Thanks
    Joe

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Sep 2010
    Link to this post
    Hello Joe Keller,

    The module uses LandingPageId property which gets the identity of the home (landing) page for the Blogs module. Inside Install method PageManager creates this node as backend page.

    Public controls like JobApplicationUpload that  inherit from SimpleView have a property LayoutTemplatePath that you can use to get or set the path of the external template to be used by the control directly through the widget designer.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Joe Keller
    Joe Keller avatar
    48 posts
    Registered:
    07 Apr 2010
    16 Sep 2010
    Link to this post
    If I override the LayoutTemplatePath, and explicitly set the property value to something like '~/templates/mytemplate.ascx' my public controls (.cs files) start breaking because they return null when trying to get a reference to the controls.
    It all works fine when I use LayoutTemplateName, and it references an embedded resource.

    At first I was thinking it just couldn't find the .ascx file but, I noticed it will throw a specific error about not being able to find the .ascx file if you don't enter the LayoutTemplatePath properly. I am not getting that error, so I assume it is finding the .ascx file just fine,

    I will try a few more things and see what happens.
    Thanks
    Joe
  4. Joe Keller
    Joe Keller avatar
    48 posts
    Registered:
    07 Apr 2010
    16 Sep 2010
    Link to this post
    Ok, I figured out what was happening, in case anyone else runs into this issue.

    For whatever reason, I was using the following code in my control wrapper properties:
    protected Panel pnlSubCategory
            {
                get
                {
                    return (Panel)base.Container.FindControl("pnlSubCategory");
                }
            }

    When I changed it to the following everything worked fine:
    protected Panel pnlSubCategory
            {
                get
                {
                    return base.Container.GetControl<Panel>("pnlSubCategory", true);
                }
            }

    Interestingly, the first code-block works as long as the template is an embedded resource and no LayoutTemplatePath has been set.

    Thanks
    Joe

  5. Anu
    Anu avatar
    72 posts
    Registered:
    17 Jun 2010
    22 Apr 2011
    Link to this post
    Helloo,
    I want to customize NewsList Template for that i have added External News Template in my Project n i specified its path in LayoutTeplatePath property as :  ~/Custom/ControlTemplates/News/ListNewsView.ascx ...  Custom Folder is in Root ... but its not refering that Template Path ... Thanks
  6. Richard Baugh
    Richard Baugh avatar
    201 posts
    Registered:
    22 Aug 2012
    22 Apr 2011
    Link to this post
    If you are talking about the News widget in 4.x, then you can just use the Widget Template section under Design in the Administration area. By adding your code to the widget template, you can easily select it for future use. The use of the LayoutTemplatePath is really intended for use in 4.x module development. If you are just using the template to style out an existing module/widget, then the Widget Template is the way to go.
6 posts, 0 answered