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

6 posts, 0 answers
  1. Ujwala
    Ujwala avatar
    1 posts
    Member since:
    Jul 2008

    Posted 28 Nov 2009 Link to this post

    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.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 30 Nov 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. southwynd
    southwynd avatar
    11 posts
    Member since:
    Jul 2009

    Posted 04 Mar 2013 Link to this post

    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>



  5. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 07 Mar 2013 Link to this post

    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.
  6. southwynd
    southwynd avatar
    11 posts
    Member since:
    Jul 2009

    Posted 07 Mar 2013 Link to this post

    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
  7. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 12 Mar 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017