Reference stylesheet/spcript from User Control

adamskangaroo

New Member
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 \[code\]<head>\[/code\] tag. For this reason I cannot use \[code\]ScriptManager.RegisterClientScriptBlock\[/code\] Other solution I found:\[code\] HtmlLink link = new HtmlLink(); link.Href = "http://stackoverflow.com/path/style.css"; link.Attributes["type"] = "text/css"; link.Attributes["rel"] = "stylesheet"; Page.Header.Controls.Add(link);\[/code\]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 \[code\]<asp:placeholder ID="Placeholder1" runat="server">\[/code\] or replace \[code\]<%=\[/code\] with \[code\]<%#\[/code\] So considering above constraints, is it possible to place \[code\]<link href='http://stackoverflow.com/questions/14444036/path' />\[/code\] and \[code\]<script src='http://stackoverflow.com/questions/14444036/path' />\[/code\] inside \[code\]<head>\[/code\] tag from User control?
 
Back
Top