The Controls collection cannot be modified because the control contains code blocks

Error:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]

Solution:

(1)

Try removing the runat=server setting in the head tag as well.

<head id="MasterHead" runat="server" >

(2)

Replace all your <%=  %> tags with <%#  %>

(3)

you need to move the javascript code block outside of the head tag.

原文地址:https://www.cnblogs.com/emanlee/p/1491805.html