解决 The Controls collection cannot be modified because the control contains code blocks
来源:动视网
责编:小采
时间:2020-11-27 22:43:03
解决 The Controls collection cannot be modified because the control contains code blocks
解决 The Controls collection cannot be modified because the control contains code blocks:在.aspx或.ascx的如果包括<%= %>,并在.aspx, .ascs中使用了AjaxToolkit中的控件,那么很可能会引发The Controls collection cannot be modified because the control contains code blocks 异常, 解决办法
导读解决 The Controls collection cannot be modified because the control contains code blocks:在.aspx或.ascx的如果包括<%= %>,并在.aspx, .ascs中使用了AjaxToolkit中的控件,那么很可能会引发The Controls collection cannot be modified because the control contains code blocks 异常, 解决办法

在.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
解决 The Controls collection cannot be modified because the control contains code blocks:在.aspx或.ascx的如果包括<%= %>,并在.aspx, .ascs中使用了AjaxToolkit中的控件,那么很可能会引发The Controls collection cannot be modified because the control contains code blocks 异常, 解决办法