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

Forums / Sitefinity SDK / Issue with adding Layout Controls

Issue with adding Layout Controls

10 posts, 0 answered
  1. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    20 Sep 2010
    Link to this post
    Hi,

    I wanted to add new Layout Controls. To experiment I followed these exact instructions using regular user controls - http://www.sitefinity.com/40/help/developer-manual/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
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    23 Sep 2010
    Link to this post
    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.
  3. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    09 Nov 2010
    Link to this post
    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..."
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    09 Nov 2010
    Link to this post
    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.
  5. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    10 Nov 2010
    Link to this post
    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?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Nov 2010
    Link to this post
    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.
  7. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    10 Nov 2010
    Link to this post
    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
  8. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    11 Nov 2010
    Link to this post
    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 :)
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Nov 2010
    Link to this post
    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.
  10. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    12 Nov 2010
    Link to this post
    Thanks much, that worked! :)
10 posts, 0 answered