Конфликт Page.ResolveUrl с Calendar Extender в Ajax

Возможный дубликат:
« Коллекцию Controls нельзя изменить, потому что элемент управления содержит блоки кода »

Каким может быть возможное решение, чтобы избежать конфликта между 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>

Я объявил источник своего javascript на главной странице


person portgas d ace    schedule 21.01.2013    source источник


Ответы (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>

это мое другое решение, основанное здесь: Коллекцию Controls нельзя изменить, поскольку элемент управления содержит блоки кода

<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();
}
person portgas d ace    schedule 21.01.2013