Possible Duplicate:
“The Controls collection cannot be modified because the control contains code blocks”
What could be the possible solution to avoid the conflict between Page.ResolveUrl
and CalendarExtender
of Ajax
?
I get this kind of error:
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
this is how I declared the 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>
I declared my the source of my javascript in Master Page
this is my solution to my problem and it work properly:
<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>
this is my another solution based here: "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>
code behind of my MasterPage:
protected void Page_Load(object sender, EventArgs e)
{
Page.Header.DataBind();
}