解决 The Controls collection cannot be modified because the control contains code blocks
摘要:在.aspx或.ascx的如果包括,并在.aspx,.ascs中使用了AjaxToolkit中的控件,那么很可能会引发"TheControl...
在.aspx或.ascx的如果包括<%= %>,并在.aspx, .ascs中使用了AjaxToolkit中的控件,那么很可能会引发"The Controls collection cannot be modified because the control contains code blocks" 异常,
解决办法如下
1. 将<%= 换为<%#
2. 在.asp或模板页中的Page_Load事件中添加如下代码
复制代码 代码如下:
Page.Header.DataBind();
【解决 The Controls collection cannot be modified because the control contains code blocks】相关文章:
★ ASP.net Substitution 页面缓存而部分不缓存的实现方法
★ ASP.NET.4.5.1+MVC5.0设置系统角色与权限
★ asp.net中IDataParameter调用存储过程的实现方法
★ ASP.NET 2.0/3.5中直接操作Gridview控件插入新记录
★ AlternatingItemTemplate类似于 ItemTemplate 元素
★ 找不到类型或命名空间名称“Server”(是否缺少 using 指令或程序集引用?)