Google Android Development Agency SASS

Thursday 21 May 2009

Editing Umbraco in canvas mode gives error

I hit a slight quirk with Umbraco today. One of the features of Umbraco is its ability to edit a page in "Canvas mode". This means your page opens in a new window and is rendered as if it was a website, but with a content editor for you to edit your content in; much nicer than using that small white editor.

Today I fired up the canvas editor for one of the pages in a new site I'm working on, only to be met with:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Hmmf. It's because in the footer of the website I'm doing:

<%=DateTime.Now.Year%>

To output the current year. Umbraco is attempting to modify the controls collection of the page to create the editor, which is not allowed when using inline code blocks.

The workaround is a bit sneaky, but simple. All you need to do is change to the databinding syntax for echoing, like this:

<%# DateTime.Now.Year %>

Now all is well, the control collection can be modified and you can bask in the glory of the Umbraco canvas editor.

No comments:

Post a Comment