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

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

5 Answers 479 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Ujwala
Top achievements
Rank 1
Ujwala asked on 29 Nov 2009, 04:18 AM
I have declared the scriptManager in the Main Master page.  This Master page calls a control which needs the TabStrip control on it.

When the code for instantiating radstripcontrol is added I get the following error: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

My MasterPage code is:

<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="ScriptManager1" runat="server" ScriptMode="Release"
        EnablePageMethods="True" EnableScriptCombine="False"
        EnableScriptGlobalization="True">
    </telerik:RadScriptManager>
       
        <cc:Navigation ID="navSite" runat="server" />
        <div>
            <asp:ContentPlaceHolder ID="cphTop" runat="server"></asp:ContentPlaceHolder>
        </div>
        <br />
    </form>
</body>

The code on the Control is:

<%@ Import Namespace="System.Xml" %>

<%@ Control Language="C#" AutoEventWireup="true"
    CodeFile="~/controls/Navigation.ascx.cs" Inherits="controls_Navigation" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>    
<!-- Navigation -->
<table class="nav" cellspacing="0" cellpadding="0">
<tr class="navrow"><td colspan="2">
    <table class="navrow" cellspacing="0" cellpadding="0">
    <tr id="navrow1">
    <asp:Repeater ID="repNav" runat="server">
        <ItemTemplate>
            <telerik:RadTabStrip ID="ItemDetailTabStrip" runat="server" SelectedIndex="0" MultiPageID="TabStripMultiPage"
            Skin="Outlook" BorderColor="#B3C17D" Width="958px" >
            <Tabs>
                <telerik:RadTab Text="Key Fields &amp; Smart Terms&#153" BorderColor="#B3C17D">
                </telerik:RadTab>
                <telerik:RadTab Text="Results" BorderColor="#B3C17D">
                </telerik:RadTab>
            </Tabs>
        </telerik:RadTabStrip>
        </ItemTemplate>
    </asp:Repeater>
    <td style="width:100%; text-align:right; padding: 0px 0px 5px 0px;"
        >&nbsp;</td>
    </tr>
    </table>
</td></tr>
</table>

Could you please advise me what to do to overcome the persistent error?
Thanks.

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Nov 2009, 06:55 AM
Hello Ujwala,

Here are some links to documents which explain about the same error and how to solve it:
The Controls collection cannot...
RadCodeBlock and RadScriptBlock

Hope this helps..
Princy.
0
southwynd
Top achievements
Rank 1
answered on 04 Mar 2013, 04:30 PM
I am getting this error.  Any ideas on how to resolve it?

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

 

Here is my aspx page.  There is no other code on the page.

 

 

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="test.aspx.vb" Inherits="TeamNICU.test" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js">
            </asp:ScriptReference>
        </Scripts>
    </telerik:RadScriptManager>
    <telerik:RadDatePicker ID="RadDatePicker1" runat="server"></telerik:RadDatePicker>
</asp:Content>



0
Nencho
Telerik team
answered on 07 Mar 2013, 02:09 PM
Hello southwynd,

I have performed some testing, based on the provided snippet of code, but I was unable to replicate the faced exception. Here is a video, demonstrating the behavior at my end.

Could you specify the version of our controls that you are using and under which browser you had faced the described issue?

Kind regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
southwynd
Top achievements
Rank 1
answered on 07 Mar 2013, 03:08 PM
Here are the versions I am using:
Telerik RadControls for ASP.NET Ajax version 2012.3.1205.45
Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18034
IE 10 and Chrome Version 25.0.1364.152 m
0
Nencho
Telerik team
answered on 12 Mar 2013, 12:04 PM
Hello southwynd,

Since I am still unable to replicate the problematic behavior at my end, I would like to ask you to submit a support ticket, along with a runnable sample attached, demonstrating the faced issue.

Kind regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TabStrip
Asked by
Ujwala
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
southwynd
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or