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 |
Product | Progress® Telerik® UI for ASP.NET AJAX |
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.
The Controls collection cannot be modified because the control contains code blocks
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>
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>