The Controls collection cannot be modified

11 posts, 0 answers
  1. Bill
    Bill avatar
    8 posts
    Member since:
    Apr 2008

    Posted 15 May 2008 Link to this post

    I have a Development and Production environment both attempting to run the RadEditor Lite version.  In Development everything works as expected.  In production when I attempt to edit a page I get te following error

    05/15/2008 18:56:14.90  w3wp.exe (0x1554)                        0x06B8 Windows SharePoint Services    General                        8nca Verbose  Application error when access /schools/test0001/Pages/default.aspx, Error=The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).   at System.Web.UI.ControlCollection.Add(Control child)     at Telerik.RadEditorUtils.RadControl.RegisterCssFile(String path)     at Telerik.RadEditorUtils.RadControl.RenderRuntimeSkin()     at Telerik.RadEditorUtils.RadControl.Page_PreRenderComplete(Object sender, EventArgs e)     at System.EventHandler.Invoke(Object sender, EventArgs e)     at System.Web.UI.Page.OnPreRenderComplete(EventArgs e)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    The layout page and web.config files are identical on both sites.  any help is appreciated.

    I have found several posts that state that you cannot have <%%> in the <head> tag.  The question is why does it work sometimes and not work others.  I do have <%%> in the <head>  but I cannot get rid of them.

    Thanks,

    Bill
  2. George
    Admin
    George avatar
    859 posts

    Posted 21 May 2008 Link to this post

    Hi Bill,

    Indeed, this problem is observed when there is a script block in the HEAD tag. To solve the problem, you should remove the script block from the head tags and put it somewhere else (e.g. put it in the body). Also please check the head for runat="server" attribute and if it is present please remove it.

    The following Google search lists a lot of forum discussions on this topic on various ASP.NET community sites:
    http://www.google.com/search?hl=en&q=The+Controls+collection+cannot+be+modified+because+the+control+contains+code+blocks+%28i.e.+%3C%25+...+%25%3E%29

    I hope this helps.

    Kind regards,
    George
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  3. Bill
    Bill avatar
    8 posts
    Member since:
    Apr 2008

    Posted 27 May 2008 Link to this post

    Hello George,

    Thank you for the feedback, but unfortunately I cannot remove either the "runat" or the <%%> from the head.  I have information that needs to be populated there.  The real question is why does this only fail some of the time?  Meaning, why does this problem not manifest itself in my development box, but only seems to be happening on production.  Is there a fix coming for this?  Have you identified to code that fails?  Is it yours or is it SharePoint itself?

    Thanks again,

    Bill Safcik
  4. George
    Admin
    George avatar
    859 posts

    Posted 29 May 2008 Link to this post

    Hi Bill,

    You can set the server tags within RadCodeBlock. Fore more information please review the following article:
    http://www.telerik.com/help/aspnet-ajax/ajxradscriptblockradcodeblock.html


    I hope this helps.

    Sincerely,
    George
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Eddie
    Eddie avatar
    66 posts
    Member since:
    May 2008

    Posted 26 Jun 2008 Link to this post

    I'm getting the same error and nothing I've read here seems to work.  I've removed all code blocks from the head and put them into a RadCodeBlock within the page but I still get this error.  If I replace the RadAjaxPanels with UpdatePanels I don't get the error.  I'm not sure what else to try, but my project is due in a couple days and I can't get pages to load with Telerik controls on them!  This should only happen if there is asp.net code blocks in the head, right?  Of course I do have Javascript and CSS references in the head of my master page, but they are referenced directly, not using any asp.net code blocks.  That can't be causing this, can it?

    Do you have any other suggestions?
  6. George
    Admin
    George avatar
    859 posts

    Posted 30 Jun 2008 Link to this post

    Hi Eddie,

    Could you please open a support ticket and send me the problematic ASPX page. I will check it and do my best to provide a solution.

    Note that, the RadCodeBlock should be used when you have server code blocks placed within the markup (most often some JavaScript functions accessing server controls) and it prevents the server error: 

    System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).


    For example:
    <head> 
     <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
       <script language="javascript" type="text/javascript">  
            function AjaxReq(args)  
           {  
               $find("<%= RadAjaxPanel1.ClientID %>").ajaxRequestWithTarget("<%= Button1.UniqueID %>", '');  
           }  
       </script> 
     </telerik:RadCodeBlock>   
    </head> 


    Looking forward to hearing from you,
    George
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. Frank
    Frank avatar
    2 posts
    Member since:
    Feb 2009

    Posted 18 Sep 2009 Link to this post

    I have the same issue but on a later version of the rad editor. Did you find a work around to this?
    Frank
  8. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 22 Sep 2009 Link to this post

    Hello Frank,

    Could you provide us with source code of you page? Also inform us which version of RadEditor for MOSS you are using.

    Thank you.

    Kind regards,
    Stanimir
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Frank
    Frank avatar
    2 posts
    Member since:
    Feb 2009

    Posted 22 Sep 2009 Link to this post

    I am running radeditormoss_4_5_6.

    The code that I need to run is:

        <%
        SPWeb myWeb = SPControl.GetContextWeb(Context);
        SPUser uCurrent = myWeb.CurrentUser;
        String domain = "gpnet";
        String SiteName = myWeb.Url;
        String CurrentPage = HttpContext.Current.Request.Url.AbsoluteUri.ToString().ToLower().Trim();
        CurrentPage = CurrentPage.Substring(CurrentPage.LastIndexOf("/")+1);
        Page.Title = CurrentPage + " - " + SiteTitle;
                  
     
        //Check for Cookie existence
        if (Request.Cookies["TermsOfUse"]==null)
        {

        //Redirect to terms page.
            Response.Redirect(SiteName + "/_layouts/GP_Custom/termsofuse/terms.aspx?OrigUrl="+ Server.UrlEncode(SiteName), true);
            //Response.Redirect("/_layouts/GP_Custom/keepalive.aspx", true);
        }
        %>

    Thanks
    Frank

  10. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 25 Sep 2009 Link to this post

    Hello Frank,

    If the code that you need to run is in the head tag, you should make sure that there is no runat="server" attribute in it.

    I hope this helps.

    All the best,
    Stanimir
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  11. Vincent Kemp
    Vincent Kemp avatar
    3 posts
    Member since:
    Feb 2009

    Posted 23 Nov 2009 Link to this post

    Probably a late reply but placing the .net code between de telerik code blocks works fine for me. The .net error doesn't show up any more. In my example I use a randomizer which doesn't work when the radcodeblocks are not placed.

    Even when the "Head" has the attribute runat="server", I have no problems.

    Example, just placed this in my PageLayout.

    <head id="Head1" runat="server">

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
      <style type="text/css">
     .homepageBanner
    {
     background-image: url('/Style%20Library/Parentix/img/homeimage<%Random random = new Random(); System.Web.HttpContext.Current.Response.Write(random.Next(1, 5));%>.png');
     background-repeat: no-repeat;
     height: 237px;
     width: 948px;
    }
    </style>

     </telerik:RadCodeBlock>  
     
    </head>


    Works fine!
Back to Top