Issue with adding Layout Controls

Posted by Community Admin on 05-Aug-2018 11:25

Issue with adding Layout Controls

All Replies

Posted by Community Admin on 20-Sep-2010 00:00

Hi,


I wanted to add new Layout Controls. To experiment I followed these exact instructions using regular user controls - www.sitefinity.com/.../pages-layouts-creating-layout-controls.html

This didn't work - I got an error saying that it wasn't a valid template.

I then tried embedding the controls in a class library - no luck there either.

Has the above instructions been tested and how would the process vary if it were resources embedded in a library - should it work?

Thanks,

Seth

Posted by Community Admin on 23-Sep-2010 00:00

Hi Seth Cleaver,

I checked the article and it is valid for the BETA. Make sure that you have added valid relative paths to the ascx file and you have build the application before trying to add the layout control on a page.

When you use custom class library you have to set

ControlType - type of your class library for instance -Telerik.Samples.LayoutControl, Telerik.Samples
LayoutTemplate - location to the embedded template.


sample

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using Telerik.Sitefinity.Web.UI;
 
namespace Templates
    class Class1 : LayoutControl
    
 
        public override string Layout
        
            get
            
                return this.CustomTempalate;
            
          
        
        public override string AssemblyInfo
        
            get
            
                return GetType().ToString();
            
            set
            
                base.AssemblyInfo = value;
            
        
 
        protected override void CreateChildControls()
        
            base.CreateChildControls();
        
 
        public string CustomTempalate = "Templates.Layouts.Column1Template.ascx";
    


Greetings,
Ivan Dimitrov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.

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

In the video, are "CustomLayout" and "LayoutControl" in any way related? And BTW, what does this mean? "...you have build the application before trying to add the layout control on a page..."

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

Hello jkregala,

The video shows that LayoutControl is a custom page layout. "LayoutControl" is the Title of Templates.Class1.

When you work with web application, you have to build the solution or restart it with a dummy change in the web.config, otherwise the changes you have made would not apply.

Kind regards,
Ivan Dimitrov
the Telerik team


Check out Telerik Trainer, the state of the art learning tool for Telerik products.

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

Hi, in the video, I did not see any reference to any physical file for the custom control "LayoutControl" in the LayoutTemplate field. (Under Administration - Tools - so on). Was the code you sampled meant to be placed in a physical .ascx file?

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

Hello jkregala,

The class is registered in Toolboxes >> PageLayouts section and this is shown in the video.

Best wishes,
Ivan Dimitrov
the Telerik team


Check out Telerik Trainer, the state of the art learning tool for Telerik products.

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

Error

Could not load file or assembly 'Templates' or one of its dependencies. The system cannot find the file specified.

Did exactly what was in the video

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

Hi Ivan, a colleague of mine came to my rescue and now we're no longer having these problems.

Anyway, how do I let these things appear? Kindly see screenshot. They are vital for the placement of Content Controls. Thanks :)

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

Hello jkregala,

Thsi is a layout element which has 4 containers, so each of them should be 25%. You can use the following CssClass when you add your new tool and below is a sample template

<%@ Control Language="C#" %>
 
<div runat="server" class="sf_cols">
    <div runat="server" class="sf_colsOut sf_4cols_1_25">
        <div runat="server" class="sf_colsIn sf_4cols_1in_25">
             
        </div>
    </div>
    <div runat="server" class="sf_colsOut sf_4cols_2_25">
        <div runat="server" class="sf_colsIn sf_4cols_2in_25">
             
        </div>
    </div>
    <div runat="server" class="sf_colsOut sf_4cols_3_25">
        <div runat="server" class="sf_colsIn sf_4cols_3in_25">
             
        </div>
    </div>
    <div runat="server" class="sf_colsOut sf_4cols_4_25">
        <div runat="server" class="sf_colsIn sf_4cols_4in_25">
             
        </div>
    </div>
</div>


Best wishes,
Ivan Dimitrov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.

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

Thanks much, that worked! :)

This thread is closed