I know this has been asked, but I have a more complicated issue than in other relevant questions.
I need to reference CSS and JS from my usercontrol.
References must be rendered inside <head>
tag. For this reason I cannot use ScriptManager.RegisterClientScriptBlock
Other solution I found:
HtmlLink link = new HtmlLink();
link.Href = "/path/style.css";
link.Attributes["type"] = "text/css";
link.Attributes["rel"] = "stylesheet";
Page.Header.Controls.Add(link);
However this ends up with "The Controls collection cannot be modified because the control contains code blocks"
The problem is those code blocks are located in master page file which I don't have a control over. So workarounds suggested in this thread are not possible. (E.g.: wrap code block in <asp:placeholder ID="Placeholder1" runat="server">
or replace <%=
with <%#
So considering above constraints, is it possible to place <link href='path' />
and <script src='path' />
inside <head>
tag from User control?