zoukankan      html  css  js  c++  java
  • asp.net当修改header时提示:The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)

    The Problem:

    后台代码:

    HtmlGenericControl jsGC = new HtmlGenericControl("script");
    jsGC.Attributes.Add("type""text/javascript");
    jsGC.Attributes.Add("src""http://www.cnblogs.com/js/Cookie.js");
    Page.Header.Controls.Add(jsGC);

     提示错误:

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

    The Solution:

    A. 把Header中的带有<%=...% >这样的代码移出。

    B. 把代码放入placeholder

    C. (1). 把<%=..%>改为:<%# ...%>

        (2). 在page_load函数中增加:Page.Header.DataBind();

    D. 动态生成。

    参考资料:http://leedumond.com/blog/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks/

  • 相关阅读:
    Tableau Sheet
    Tableau Dashboard
    jQuery基础
    Tableau学习
    SQL小操作
    C#文件压缩成.Zip
    划水日记之大哥带我走渗透I
    各种推导式
    生成器表达式 (重点)
    生成器 生成器函数
  • 原文地址:https://www.cnblogs.com/lfzwenzhu/p/1700430.html
Copyright © 2011-2022 走看看