LayoutTemplatePath - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development


  • LayoutTemplatePath
  • 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.


  • 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.

    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  • 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.
  • 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
                    return (Panel)base.Container.FindControl("pnlSubCategory");

    When I changed it to the following everything worked fine:
    protected Panel pnlSubCategory
                    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.


  • 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
  • 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.