控件集合无法修改,因为控件包含代码块(即<% ...%>)ajax toolkit html editor

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18097931/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 11:55:38  来源:igfitidea点击:

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

javascripthtmlasp.netmaster-pagesajaxcontroltoolkit

提问by Bip

<%@ 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. <% ... %>).

我尝试添加带有命名空间的母版页 ajax html 编辑器,但我有这个错误: System.Web.HttpException:无法修改控件集合,因为控件包含代码块(即 <% ... %>)。

how to fix it? thanks for your answers.

如何解决?感谢您的回答。

回答by Harshil Raval

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.

我以前遇到过这个错误。解决方案是,检查您的母版页,如果您有带有 <% ... %> 块的 javascript,然后将其从 head 中删除并添加到 body 部分中。

Hope it helps you.

希望对你有帮助。

回答by Mahmoude Elghandour

Use This

用这个

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

1-用 <%# 而不是 <%= 替换代码块

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………

快乐编码……

回答by phoenixAZ

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>

回答by Nguy?n ??c Tùng

Remove javascript block from header and add to body.

从标题中删除 javascript 块并添加到正文。

回答by drogon

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

带有 runat=server 的标记中的任何数据绑定表达式都会引发此错误。

回答by doglin

You should wrap around your script tags

你应该环绕你的脚本标签