Monday, May 16, 2016

Sitecore preview and experience editor error

When using the preview mode or experience editor, the following error may occur:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
This is because the page contains code rendering blocks (the <%= tag) which should always be surrounded by a runat="server" control. This is stated in Sitecore documentation as:
When necessary, use code rendering blocks only within server controls. For example, the following code contains a code rendering block (the content between <%= and %>):
Therefore a solution would be to use a placeholder for example:

<asp:PlaceHolder runat="server">
    <%=TextyText%>
</asp:PlaceHolder>

No comments:

Post a Comment