The Controls collection cannot be modified because the control contains code blocks
This article will explain how to avoid the "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)" error message on your site.
This error occurs because the page (page layout, web part code) contains code blocks which are not resolved correctly in some special cases. The example below shows how to avoid this issue and how to use the code in a layout in the proper way:
<asp:Literal runat="server" ID="test" Text="test" />
<script runat="server">
protected void Page_PreRender(object sender, EventArgs e)
{
test.Text = CMS.GlobalHelper.ResHelper.GetString("general.ok");
}
</script>
-jo-
See also: Forum thread 1
Forum thread 2Applies to: Kentico CMS 6.x, 7.x