This is my code:
Page.Header.Controls.Add(new LiteralControl("<link rel=\"stylesheet\" href=\"" + Urls.FindCSS("jquery-modalpopup.css") + "\" type=\"text/css\" />"));
I’m new to ASP.NET and to using Literals but from what I read this should be valid yet I get this exception at runtime:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
I searched for similar questions of course but the use <%# solution aka databinding doesn’t work for me.
If you have any solutions or recommendations I’m listening.
You need to remove
<% ... %>from your header and use another Literal instead.