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

The Controls collection cannot be modified

10 Answers 239 Views
WebParts for SharePoint
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 16 May 2008, 02:07 AM
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

10 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 21 May 2008, 10:12 AM
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
0
Bill
Top achievements
Rank 1
answered on 27 May 2008, 06:47 PM
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
0
George
Telerik team
answered on 29 May 2008, 01:29 PM
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
0
SSDApplications
Top achievements
Rank 2
answered on 26 Jun 2008, 05:02 PM
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?
0
George
Telerik team
answered on 30 Jun 2008, 12:17 PM
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
0
Frank
Top achievements
Rank 1
answered on 18 Sep 2009, 05:46 PM
I have the same issue but on a later version of the rad editor. Did you find a work around to this?
Frank
0
Stanimir
Telerik team
answered on 22 Sep 2009, 06:31 AM
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.
0
Frank
Top achievements
Rank 1
answered on 22 Sep 2009, 12:04 PM
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

0
Stanimir
Telerik team
answered on 25 Sep 2009, 07:53 AM
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.
0
Lennart Burkels
Top achievements
Rank 1
answered on 23 Nov 2009, 04:30 PM
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!
Tags
WebParts for SharePoint
Asked by
Bill
Top achievements
Rank 1
Answers by
George
Telerik team
Bill
Top achievements
Rank 1
SSDApplications
Top achievements
Rank 2
Frank
Top achievements
Rank 1
Stanimir
Telerik team
Lennart Burkels
Top achievements
Rank 1
Share this question
or