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

53 posts, 0 answers
  1. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 02 May 2008 Link to this post

    Hi Brad,

    Thank you for your feedback.
    I will pass it along to our development team. They will definately review it carefully, and consider a modification of the control for one of the upcoming versions.

    Kind regards,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  2. David Bows
    David Bows avatar
    50 posts
    Member since:
    Dec 2005

    Posted 06 May 2008 Link to this post

    I agree - the whole RadControlBlock thing is terrible.  This is a HUGE reason that I cannot take advantage of the new stuff.  Telerik you have to realize you have too many customers now to go and require them to make this type of change to stable applications to continue to use your controls.  It puts all of our applications at risk and cost a ton of money in testing and support.

    David
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. cayates
    cayates avatar
    71 posts
    Member since:
    Feb 2007

    Posted 07 May 2008 Link to this post

    Hello, I am running into this same problem as well.  I would also like to express the same dissatisfaction that the others in this forum have expressed.  It was a very bad decision on the telerik developers part to force your customers to sourround all instances of <%= %> with the RadCodeBlock.  It should have been realized that this type of requirement would cause too many problems and too big of an inconvenience for customers with large projects who wants to upgrade.  It's an extra process to remember and keep track of.  The nature of asp.net lends itself to nested pages, objects, and reusable controls.  I have a feeling I will constantly be running into this error and subsequently having to search each layer of nested pages and web controls for <%=%> tags, what a pain!  Plus it clutters up the aspx file even more.

    </rant>
  5. ewart
    ewart avatar
    221 posts
    Member since:
    Jan 2007

    Posted 20 May 2008 Link to this post

    Thank goodness for this thread, I was able to wrap my JS with the RadCodeBlock and that worked.   At this stage I'm only converting 5 pages (of about 200) in the website.  I'm wondering if, during the future conversion process I should be using a different method instead of the code <% %> tags for locating my ajax object.

    At the moment my JS code is like:

    var ajaxManagerObject = window["<%= rAjax.ClientID  %>"]; // Locate AJAX Object

    But perhaps there is a better way for future? 

    cheers
    ewart
  6. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 21 May 2008 Link to this post

    Hello ewart,

    Better approach might be to use the $find method of the ASP.NET AJAX framework which is a shortcut for the findComponent() method. Review the code snippets from this topic in the online documentation for more info (it also outlines the changes we made compared to the Prometheus version of RadAjax):

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

    Best regards,
    Stephen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. wvanhooijdonk
    wvanhooijdonk avatar
    16 posts
    Member since:
    Feb 2007

    Posted 26 Jun 2008 Link to this post

    Where can I find any newsupdate on this (RadCodeBlock) issue?

    I'm also having the same trouble like Jason with the exception 'The controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)' and I'm wordking in the 2008 Q1 HotFix.
    I'm also using DotNetNuke which headers or code blocks I do not whish to touch. Everything worked fine with 2007 Q3...

    Thanks in advance.
  8. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 30 Jun 2008 Link to this post

    Hi,

    At present, the only possibility to remove this exception is to wrap the relevant JavaScript code in a RadCodeBlock. I hope that this approach does not cause you any inconvenience.

    Regards,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. wvanhooijdonk
    wvanhooijdonk avatar
    16 posts
    Member since:
    Feb 2007

    Posted 30 Jun 2008 Link to this post

    I'm sorry to say this, but this probably prevents me from using any Telerik controls from now on. This will likely be followed by removing our subscription.
    Like I said: a developer is not always able to change third party scripts.
    Please inform me of any improvements on this issue.
  10. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 30 Jun 2008 Link to this post

    Hello,

    I'm afraid there is misunderstanding here. You don't have to change anything in the third-party control scripts. The error is resolved simply by wrapping anything containing the code block within RadCodeBlock. It won't change anything else either in the layout or in the modules functionality. The RadCodeBlock and RadScriptBlock are described in details here.

    I hope this helps.

    Sincerely yours,
    Konstantin Petkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  11. wvanhooijdonk
    wvanhooijdonk avatar
    16 posts
    Member since:
    Feb 2007

    Posted 30 Jun 2008 Link to this post

    Sorry if I misunderstood. I'd like to re-illustrate my problem here:
    1. I use the Telerik controls within a DotNetNuke module. DNN uses script blocks which I don't want to change.
    2. I don't use any code or script blocks myself (just Telerik controls like RadGrid, RadComboBox)
    3. Version 2007 Q3 worked fine
    4. Version 2008 Q1 gives me the 'The Controls collection cannot be modified...' error

    This is the issue I was complaining about. At first, I understood that I needed to encapsulate the script DNN script blocks with RadScriptBlock, but now you say I 'don't have to change anything in the third-party control scripts'?
    Please inform me about any misinterpretations and what I should do to get rid of this error.

    Thanks,
    Willem
  12. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 30 Jun 2008 Link to this post

    Hi,

    What I meant is to wrap those code blocks you have in the header within RadCodeBlock to resolve the error. It won't change anything in the functionality as well as in the layout.

    Alternatively, you can try disabling the page head update through the EnablePageHeadUpdate="false" RadAjaxControl setting.

    Let us know whether this works for you.

    Greetings,
    Konstantin Petkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  13. wvanhooijdonk
    wvanhooijdonk avatar
    16 posts
    Member since:
    Feb 2007

    Posted 30 Jun 2008 Link to this post

    Ok, I will rephrase my question: how can I wrap the DNN code blocks in the header without changing the DNN source (from within the DNN module)?
    Thank you for your swift response.
  14. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 01 Jul 2008 Link to this post

    Hi wvanhooijdonk,

    You cannot avoid changing the DNN module source. Have you tried EnablePageHeadUpdate="false" suggestion?

    Sincerely yours,
    Konstantin Petkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  15. Jonathan
    Jonathan avatar
    134 posts
    Member since:
    Sep 2007

    Posted 27 Aug 2008 Link to this post

    Could you give me the exact syntax for wrapping the following code tags in <telerik:radcodeblock>

    <

    input class="norm" id="btnLookup1" onclick= "openLookupWindow('<%= ddlSearchField1.ClientID %>','<%= txtTerm1.ClientID %>');" type="button" value="..."/>

    There is an AJAX manager on the page and the usual error occurs because of this line.

    Thanks

  16. Bodevain Svensson
    Bodevain Svensson avatar
    195 posts
    Member since:
    May 2006

    Posted 28 Aug 2008 Link to this post

    Based on the discussion in this thread, my assumption would be to wrap the entire input type="button" control inside RadCodeBlock. Another thing that should work would be to set runat=server attribute for this html input and assign the onclick handler on the server passing the clientids of the controls in question as arguments.

    Bodevain
  17. Andreas Ladis
    Andreas Ladis avatar
    17 posts
    Member since:
    Mar 2009

    Posted 31 Mar 2009 Link to this post

     

    I added a RadCodeBlock around my javascript section and that seemed to fix it. 

    Thanks...  Eleni
  18. DK
    DK avatar
    72 posts
    Member since:
    Jun 2009

    Posted 08 Oct 2009 Link to this post

    I have also added radcodeblock it works fine now.
    but some panels are not updated with some controls/
    why it is happening so?
    i have a radcombobox and a text box .
    on selected index change of the combobox i m  updating  a panel say panDetail and also on text change of the textbox i am updating the same panel.
    it works fine for textbox but in case  of radcombobx the panel is not updated?
    why so?
  19. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 09 Oct 2009 Link to this post

    DK-

    A couple things to check:

    1. First, make sure that your Combobox works with a PostBack. If it works with a normal PostBack, it should continue to work when you add the "ajaxification."
    2. Second, one thing often overlooked with Combobox is the AutoPostBack property. Make sure AutoPostBack property is set to true on your RadCombobox to ensure a server event is fired when an action is performed.

    Hope that helps.

    -Todd
  20. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 09 Oct 2009 Link to this post

    DK-

    A couple things to check:

    1. First, make sure that your Combobox works with a PostBack. If it works with a normal PostBack, it should continue to work when you add the "ajaxification."
    2. Second, one thing often overlooked with Combobox is the AutoPostBack property. Make sure AutoPostBack property is set to true on your RadCombobox to ensure a server event is fired when an action is performed.

    Hope that helps.

    -Todd
  21. Juan
    Juan avatar
    3 posts
    Member since:
    Nov 2010

    Posted 04 Mar 2011 Link to this post

    Thanks Jason Maronge wrapping my code in the RadCodeBlock fix my problem. Im using ajax toolkit for the autocomplete extender and calendar extender. And with telerik the rad grid with nestedview. In my javascript Im accesing server controls id for the autocomplete behavior.
  22. Mahesh
    Mahesh avatar
    6 posts
    Member since:
    Jan 2013

    Posted 11 Jan 2013 Link to this post

    Dear DK
    I have the same problem .........
    I am filling other combo on selected index change of another combo that combo not updated
    kindly let me know if you got answer
  23. Rama
    Rama avatar
    22 posts
    Member since:
    Jun 2012

    Posted 17 Jan 2013 Link to this post

    this solution is absolute for the problem .

    Thanks

    Rama
  24. Tim
    Tim avatar
    85 posts
    Member since:
    Aug 2008

    Posted 22 Apr 2013 Link to this post

    Ok, here is a workaround.  This is what I did from a Website created in ASP.NET 4.5 using the standard built-in web template. 

    Basically, the built-in template has a header like this:
    <head runat="server">
        <title ><%: Page.Title %> - My Site</title>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
         
        <asp:PlaceHolder runat="server">
        <%: Scripts.Render("~/bundles/modernizr") %>
        </asp:PlaceHolder>
         
        <webopt:BundleReference runat="server" Path="~/Content/css" />
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <asp:ContentPlaceHolder runat="server" ID="HeadContent" />
    </head>
    So, you've added either a RadAjaxManager or RadAjaxPanel on your MasterPage or Form.  And you get the same error mentioned in this Thread.  So the recommendation is to remove the "runat=server" from your head tag which then breaks the whole site and causes all sorts of redesign, meetings, pulling of hair, nashing of teeth, etc.  Or, you implement this horrendous solution of wrapping RadCodeBlocks around everything and then you head tag looks like this:
    <head runat="server">
        <telerik:RadCodeBlock runat="server">
        <title><%: Page.Title %> - My Site</title>
        </telerik:RadCodeBlock>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
         
        <telerik:RadCodeBlock runat="server">
        <asp:PlaceHolder runat="server">
        <%: Scripts.Render("~/bundles/modernizr") %>
        </asp:PlaceHolder>
        </telerik:RadCodeBlock>
         
        <telerik:RadCodeBlock runat="server">
        <webopt:BundleReference runat="server" Path="~/Content/css" />
        </telerik:RadCodeBlock>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <asp:ContentPlaceHolder runat="server" ID="HeadContent" />
    </head>

    So then you realize you have to retrain all developers to NEVER use any standard built-in ASP.NET syntax such as "<%:" or "<%=", etc.  Then you realize, this doesn't make any sense, and you say to yourself: "I noticed that the placeholder control had a "runat=server" and without wrapping that control in a RadCodeBlock, everything worked just fine!".

    Ahh, so now the solution presents itself.  All we need are server controls wrapping the elements giving us this problem!  But, I don't want to wrap my "title" and all my "H1-H6" tags with asp:Panel controls either!  So, here it is, the solution to all this mess...
    simply set your elements to run from the server (ex. title runat='server').

    And finally, the head tag which works with RadAjax!
    <head runat="server">
        <title runat="server"><%: Page.Title %> - My Site</title>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
         
        <asp:PlaceHolder runat="server">
        <%: Scripts.Render("~/bundles/modernizr") %>
        </asp:PlaceHolder>
         
        <webopt:BundleReference runat="server" Path="~/Content/css" />
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <asp:ContentPlaceHolder runat="server" ID="HeadContent" />
    </head>

    And viola!  No RadCodeBlocks!!!

    Now, this may not work in all situations, but it has saved me from over-complicating the simplest things in my site.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017