Custom layout widget's widget-placeholder's properties cannot be edited
Hi!
If you create a layout widget which has custom template that includes an SF layout element (the three div's of them anyway), you can add content there as expected. However - the layout side offers you a possibility to edit the layout component's width, spacing and classnames, but these do not work and the edits are not persisted. To be specific, I wanted to be able to set the width, but noticed that even adding another classname (or removing some of them) did not take effect from the preview.
1. create a custom layout widget which has placeholder, some inner divs and a custom template file. I provided samples underneath that should cause the bug to appear. Set the custom template itself (.ascx file) to be an embedded resource and to be returned when requested (as per the guide for custom templates shows).
.code
public
class
Box : 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 =
"SitefinityWebApp.CustomLayouts.Box.ascx"
;
<%@ Control Language="C#" %>
<
asp:PlaceHolder
ID
=
"Box"
runat
=
"server"
>
<
div
class
=
"box_wrap"
runat
=
"server"
>
<
div
class
=
"box_l"
runat
=
"server"
>
<
div
class
=
"box_r"
runat
=
"server"
>
<
div
class
=
"box_content_wrap"
runat
=
"server"
>
<
div
runat
=
"server"
class
=
" sf_cols "
>
<
div
runat
=
"server"
class
=
"u_inner_content_wrap sf_colsOut sf_1cols_1_100 "
>
<
div
runat
=
"server"
class
=
" sf_colsIn sf_1cols_1_100 "
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
<
div
class
=
"box_br"
runat
=
"server"
>
</
div
>
</
div
>
</
asp:PlaceHolder
>
Hello Lasse,
I found the problem. It is in the implementation of the custom control. The Layout property must be implemented as follows:
public
override
string
Layout
get
var layout =
this
.ViewState[
"Layout"
]
as
string
;
if
(
string
.IsNullOrEmpty(layout))
layout =
this
.CustomTempalate;
return
layout;
This would solve the problem with persisting the changes of the layout made from the page editor. I checked in our manual and found out that this is not covered there. We will update it.
However, another problem exists with the template(.ascx) you posted. When you edit it from the page editor it will be truncated to the DIV that has the "sf_cols" class. The exact template you posted will be truncated after edit to this:
<
div
runat
=
"server"
class
=
"sf_cols"
>
<
div
runat
=
"server"
class
=
"u_inner_content_wrap sf_colsOut sf_1cols_1_100 "
>
<
div
runat
=
"server"
class
=
" sf_colsIn sf_1cols_1_100 "
>
</
div
>
</
div
>
</
div
>
We will investigate further to see why this truncation happens. Anyway, if you put everything under the "sf_cols" div, no truncation will occur. For example:
<%@ Control Language="C#" %>
<
asp:PlaceHolder
ID
=
"Box"
runat
=
"server"
>
<
div
runat
=
"server"
class
=
"sf_cols"
>
<
div
runat
=
"server"
class
=
"u_inner_content_wrap sf_colsOut sf_1cols_1_100 "
>
<
div
runat
=
"server"
class
=
" sf_colsIn sf_1cols_1_100 "
>
</
div
>
</
div
>
<
div
class
=
"box_br"
runat
=
"server"
>
</
div
>
</
div
>
</
asp:PlaceHolder
>
I hope this helps you solve the task you are working on.