This is a migrated thread and some comments may be shown as answers.

The dreaded "Controls collection cannot be modified" error

3 Answers 92 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 08 May 2008, 09:28 PM
I'm attempting to convert my pages using the ASP.Net controls to the ASP.Net Ajax controls. I have a page with a Grid and Menu, and got those converted fine, but I'm receiving errors when I try to convert the RadAjaxManager.

If I drop this code onto the page:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
       
<AjaxSettings>
           
<telerik:AjaxSetting AjaxControlID="RadGrid1">
               
<UpdatedControls>
                   
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"/>
               
</UpdatedControls>
           
</telerik:AjaxSetting>
       
</AjaxSettings>
   
</telerik:RadAjaxManager>

Then I get the "The Controls collection cannot be modified because the control contains code blocks" error. I'm using a master page, and there's no code inside the <head></head> tag, just a title and a link for a .css file. As soon as I remove the RadAjaxManager control, it works fine (just without ajax...).

Suggestions?

Bill

3 Answers, 1 is accepted

Sort by
0
Matt
Top achievements
Rank 1
answered on 09 May 2008, 03:15 AM
Figured it out, I had to wrap a script block containing <% %> with:

<telerik:RadCodeBlock ID="cb1" runat="server">
</telerik:RadCodeBlock>
0
Pranav Dagaonkar
Top achievements
Rank 1
answered on 25 Jul 2008, 07:41 AM
I wrapped my JS inside the RadCodeBlock. But I'm still getting the error. I also checked there is no scripts in <head>. What else could be wrong?
0
Sebastian
Telerik team
answered on 25 Jul 2008, 07:47 AM
Hi Pranav,

There might be some other place or other control included in the page (a user control or some custom control for example) where the server code blocks generate the exception. Perform a global search in your project to verify that and read the following topic from the online documenation for more details:

http://www.telerik.com/help/aspnet-ajax/ajxradscriptblockradcodeblock.html

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
Matt
Top achievements
Rank 1
Answers by
Matt
Top achievements
Rank 1
Pranav Dagaonkar
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or