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

[Solved] How to determine what needs a RadCodeBlock

1 Answer 196 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
mjones
Top achievements
Rank 1
mjones asked on 11 Jun 2008, 10:05 PM

If you find yourself with an elusive “The controls collection cannot be modified” error, we’ve figured out some details that might help.  The docs (http://www.telerik.com/help/aspnet-ajax/ajxmigration.html) state that you need to add a RadCodeBlock around all <script> tags that have a <%= somewhere in them. 

Via a support ticket, we learned that all <%= tags need a RadCodeBlock.  Adding RadCodeBlocks throughout an application any larger than a small website can be a daunting task.  In our application, on a single page, I ended up finding two particular <%= tags that needed a RadCodeBlock.

But what really got us thinking was all the ones that did not need a RadCodeBlock.  As we looked, what we found was that when a <%= was contained within a control that was runat=”server”, it did not need a RadCodeBlock.  All the RadCodeBlock does is give you a container control that is runat=”server”

Here’s an example of a place which threw the “The controls collection cannot be modified…” error:

      <fieldset>

            <legend>

                  <%=Resources.Atlas.Recipients%>

            </legend>

Simply adding ‘runat=”server”’ to the legend tag fixes the problem.

      <fieldset>

            <legend runat="server">

                  <%=Resources.Atlas.Recipients%>

            </legend>

Note however, that it is not adequate to add the runat=”server” to the fieldset tag.  The immediate parent MUST be runat=server.

It seems that a good regular expression or a simple little application that parses aspx/ascx files could easily find every location where you need to add a runat="server" to an immediate parent.

Warmest Regards,

Matt

1 Answer, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 13 Jun 2008, 11:56 AM
Hi mjones,

Thanks for sharing your findings with the community. The docs are already updated to avoid any further confusion.

Best wishes,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Ajax
Asked by
mjones
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Share this question
or