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

后端 未结 7 1879
别那么骄傲
别那么骄傲 2020-11-30 02:35

I am trying to create dynamic meta tags in C# but it gives the following error:

The Controls collection cannot be modified because the control conta

7条回答
  •  春和景丽
    2020-11-30 03:27

    Check out the solutions at "The Controls collection cannot be modified because the control contains code blocks"

    The accepted solution on the other question worked for me -- change instances of <%= to <%#, which converts the code block from Response.Write to an evaluation block, which isn't restricted by the same limitations.

    In this case though, like the accepted solution here suggests, you should add the controls to something other than a masterpage ContentPlaceHolder element, namely the asp:Placeholder control suggested.

提交回复
热议问题