【问题标题】:The Controls collection cannot be modified because the control contains code blocks(i.e.<% ...%>) ajax toolkit html editor无法修改 Controls 集合,因为该控件包含代码块(即 <% ...%>)ajax 工具包 html 编辑器
【发布时间】:2013-08-08 12:10:56
【问题描述】:
<%@ 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>

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

如何解决?谢谢你的回答。

【问题讨论】:

    标签: javascript html asp.net master-pages ajaxcontroltoolkit


    【解决方案1】:

    我以前遇到过这个错误。解决方案是,检查您的母版页,如果您有带有 块的 javascript,则将其从头部删除并添加到正文部分。

    希望对你有帮助。

    【讨论】:

    • 我认为,错误原因不是js。当我删除 ajaxtoolkit 部分时,没有错误
    • 你解决了我的问题,我只需要将整个脚本放在 conetnetholder 头中。
    【解决方案2】:

    使用这个

    1-将代码块替换为

    将代码块替换为

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

    添加代码后运行您的应用程序,它将为您工作。

    快乐编码…………

    【讨论】:

      【解决方案3】:

      谢谢 - 这也是我的问题。

      我改变了:

       <script src="<%=Page.ResolveClientUrl(String.Format("~/Scripts/jquery-1.7.1{0}.js", IIf(Bshifter4.MvcApplication.UseMinify, ".min", ".chirp")))%>" type="text/javascript"></script>
      

      【讨论】:

        【解决方案4】:

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

        【讨论】:

          【解决方案5】:

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

          【讨论】:

            【解决方案6】:

            你应该环绕你的脚本标签

            【讨论】:

            • 投反对票,因为没有关于 OP 应该做什么的细节
            猜你喜欢
            • 1970-01-01
            • 2014-05-15
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2011-06-27
            相关资源
            最近更新 更多