【问题标题】:Page.ResolveUrl conflict with Calendar Extender of Ajax [duplicate]Page.ResolveUrl 与 Ajax 的日历扩展器冲突 [重复]
【发布时间】:2013-01-21 08:16:54
【问题描述】:

可能重复:
“The Controls collection cannot be modified because the control contains code blocks”

有什么可能的解决方案来避免Page.ResolveUrlCalendarExtenderAjax 之间的冲突?

我收到这种错误:

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


    【解决方案1】:

    这是我的问题的解决方案,它可以正常工作:

    <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();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多