可能重复:
“The Controls collection cannot be modified because the control contains code blocks”
避免Page.ResolveUrl
的{{1}}和CalendarExtender
之间发生冲突的可能解决办法是什么?
我遇到了这种错误:
Ajax
这是我宣布 Page.ResolveUrl
的方式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
我在母版页
中宣布了我的javascript来源答案 0 :(得分:0)
这是我解决问题的方法,它运作正常:
<script src="../Style/javascript/jquery-1.7.1.js" type="text/javascript"></script>
<script src="../Style/javascript/jquery.toastmessage.js" type="text/javascript"></script>
<script src="../Style/MyMessages.js" type="text/javascript"></script>
这是我的另一个解决方案: "The Controls collection cannot be modified because the control contains code blocks"
<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>
我的MasterPage背后的代码:
protected void Page_Load(object sender, EventArgs e)
{
Page.Header.DataBind();
}