无法修改 Controls 集合,因为该控件包含代码块(即 <% ... %>)。无法解决此错误

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

尝试了很多但无法弄清楚这个错误,我正在使用脚本和 ajax 工具包并且我更改为 <%= ...%> 并且还添加了 page.header.databind() 但没有用

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

任何人都可以帮助我

我的堆栈跟踪是

[HttpException (0x80004005): The Controls collection cannot be modified    because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +9871215
   AjaxControlToolkit.ScriptObjectBuilder.RegisterCssReferences(Control  control) in f:\TeamCity\buildAgent\workacd78aa4c25314\Server  \AjaxControlToolkit\ExtenderBase\ScriptObjectBuilder.cs:323
  AjaxControlToolkit.ExtenderControlBase.OnLoad(EventArgs e) in f:\TeamCity\buildAgent\workacd78aa4c25314\Server\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs:305
  System.Web.UI.Control.LoadRecursive() +54
  System.Web.UI.Control.LoadRecursive() +145
  System.Web.UI.Control.LoadRecursive() +145
  System.Web.UI.Control.LoadRecursive() +145
  System.Web.UI.Control.LoadRecursive() +145
 System.Web.UI.Page.ProcessRequestMain(Boolean    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772

如果 header 中没有数据绑定表达式 (<%# %>),则调用 Page.Header.Databind() 不会执行任何操作。 <%= ...%> 是一个代码块,而不是数据绑定表达式。只需尝试将其更改为 <%# ... %>