【发布时间】:2013-01-21 08:16:54
【问题描述】:
可能重复:
“The Controls collection cannot be modified because the control contains code blocks”
有什么可能的解决方案来避免Page.ResolveUrl 和CalendarExtender 的Ajax 之间的冲突?
我收到这种错误:
Server Error in '/Maitenance' Application.
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
System.Web.UI.ControlCollection.Add(Control child) +8721975
AjaxControlToolkit.ScriptObjectBuilder.RegisterCssReferences(Control control) in c:\TeamCity\buildAgent\work\86982cda3515e83b\Server\AjaxControlToolkit\ExtenderBase\ScriptObjectBuilder.cs:323
AjaxControlToolkit.ExtenderControlBase.OnLoad(EventArgs e) in c:\TeamCity\buildAgent\work\86982cda3515e83b\Server\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs:305
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Control.LoadRecursive() +146
System.Web.UI.Control.LoadRecursive() +146
System.Web.UI.Control.LoadRecursive() +146
System.Web.UI.Control.LoadRecursive() +146
System.Web.UI.Control.LoadRecursive() +146
System.Web.UI.Control.LoadRecursive() +146
System.Web.UI.Control.LoadRecursive() +146
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
这就是我声明 Page.ResolveUrl
的方式<script src="<%=Page.ResolveUrl("~")%>Style/javascript/jquery-1.7.1.js" type="text/javascript"></script>
<script src="<%=Page.ResolveUrl("~")%>Style/javascript/jquery.toastmessage.js" type="text/javascript"></script>
<script src="<%=Page.ResolveUrl("~")%>Style/MyMessages.js" type="text/javascript"></script>
我在 Master Page
中声明了我的 javascript 的来源【问题讨论】:
标签: javascript jquery ajax calendarextender