I was recently adding Script Bundling to my ASP.NET Web Forms Web Application, when I suddenly encountered this error message:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
Well, this was how my code was placed on the page originally:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
Well, this was how my code was placed on the page originally:
<%: Scripts.Render("~/bundles/jquery") %>
<%: Scripts.Render("~/bundles/jqueryUI") %>
However, after taking a look at Microsoft's solution to this problem, I discovered that I had to surround these code blocks with a PlaceHolder control!!
Therefore, I had to modify my code to look like the following:
<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/bundles/jquery") %>
<%: Scripts.Render("~/bundles/jqueryUI") %>
<%: Scripts.Render("~/scripts/custom") %>
</asp:PlaceHolder>
Once I did that, my code worked just as expected!!
No comments:
Post a Comment