The Controls collection cannot be modified because the control contains code blocks(i.e.<% ...%>) ajax toolkit html editor
Asked Answered
E

6

6
<%@ Page Language="C#" MasterPageFile="~/master/111.master" AutoEventWireup="true" CodeFile="Template.aspx.cs" Inherits="_Template" Title="Untitled Page" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %>


<asp:Content ID="Content3" ContentPlaceHolderID="cphhead" Runat="Server">   
    <script type="text/javascript" src="../css-js/jquery-1.8.3.min.js"></script>
</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="cphcontent" Runat="Server">
     <cc1:Editor ID="Editor1" Width="1028px" Height="300px" runat="server" SuppressTabInDesignMode="true" ActiveMode="Design" />                  
</asp:Content>


 <asp:Content ID="Content5" ContentPlaceHolderID="cphFooterJS" Runat="Server">
        </asp:Content>

I try to add master page ajax html editor with namespace but I have this err: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

how to fix it? thanks for your answers.

Earthshaker answered 7/8, 2013 at 8:5 Comment(0)
P
31

I have faced this error before. Solution is, check in your master page, if you have javascript with <% ... %> block, then remove it from head and add in body section.

Hope it helps you.

Petrology answered 7/8, 2013 at 9:15 Comment(2)
I think, error reason is not js. When I removed ajaxtoolkit part,there is no errEarthshaker
You solved my problem, i just had to put the whole scripts in the conetnetholder head.Sunglass
L
9

Use This

1-Replace the code block with <%# instead of <%=

After replace code block with <%# instead of <%= add following code in page load

protected void Page_Load(object sender, EventArgs e)
{
Page.Header.DataBind();    
}

After add code run your application it will work for you.

Happy Coding………

Lynnelle answered 26/12, 2013 at 12:47 Comment(0)
P
2

Thank you - this was also my issue.

I altered:

 <script src="<%=Page.ResolveClientUrl(String.Format("~/Scripts/jquery-1.7.1{0}.js", IIf(Bshifter4.MvcApplication.UseMinify, ".min", ".chirp")))%>" type="text/javascript"></script>
Pretermit answered 17/12, 2013 at 20:29 Comment(0)
D
0

Remove javascript block from header and add to body.

Diabetic answered 8/3, 2017 at 9:34 Comment(0)
I
0

Any databinding expressions in a tag with runat=server with throw this error.

Iraidairan answered 15/8, 2017 at 20:38 Comment(0)
C
-2

You should wrap around your script tags

Cassius answered 28/4, 2015 at 16:1 Comment(1)
Downvoted because there is no detail as to what the OP should doEscheat

© 2022 - 2024 — McMap. All rights reserved.