Skip to content

Latest commit

 

History

History
77 lines (63 loc) · 1.91 KB

cannot-modify-control-collection-because-of-code-blocks.md

File metadata and controls

77 lines (63 loc) · 1.91 KB
title page_title description slug tags type category res_type published
Controls Collection Cannot Be Modified because of Code Blocks Error Occurs
Controls Collection Cannot Be Modified because of Code Blocks Error Occurs
When working with Telerik UI for ASP.NET AJAX, I get a controls collection cannot be modified because the control contains code blocks error message.
cannot-modify-control-collection-because-of-code-blocks
telerik, asp, net, ajax, troubleshooting, controls, collection, cannot, be, modified, because, the, control, contains, code, blocks, error
troubleshooting
knowledge-base
kb
true

Environment

Product Progress® Telerik® UI for ASP.NET AJAX

Description

When working with Telerik UI for ASP.NET AJAX, I get an error that the controls collection cannot be modified because the control contains code blocks.

Error Message

The Controls collection cannot be modified because the control contains code blocks

Cause

The possible cause for this issues is that the code block is inside the head tag, for example:

<head id="Head1" runat="server">
  <script type="text/javascript">
  var grid = $find('<%= RadGrid1.ClientID %>');
  ...
  </script>
</head>
<body>
...
</body>

Solution

To solve this issue, move the code block (<% ... %>) outside the head tag:

<head id="Head2" runat="server">
<telerik:RadCodeBlock id="RadCodeBlock1" runat="server">
   <script type="text/javascript">
       var grid = $find('<%= RadGrid1.ClientID %>');
       ...
   </script>
</telerik:RadCodeBlock>
</head>
<body>
...
</body>
or
<head id="Head3" runat="server">
</head>
<body>
   <telerik:RadCodeBlock id="RadCodeBlock1" runat="server">
   <script type="text/javascript">
       var grid = $find('<%= RadGrid1.ClientID %>');
       ...
   </script>
   </telerik:RadCodeBlock>
</body>