Trying to link an external css page to a child page to override css from the master page. Old asp.net issue of order of building page causes problems. One solution is to use the htmlhead control to insert css link. I have added <head id="pageHead" runat="server"> to the master page. The below code is suggested in the code behind or page_load as below but it is erroring in the below form. What am I missing? <script runat="server"> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) HtmlLink link = new HtmlLink(); link.Href = "App_Themes/Theme1/StyleSheet.css"; link.Attributes.Add("type", "text/css"); link.Attributes.Add("rel", "Stylesheet"); link.Attributes.Add("media", "all"); this.Header.Controls.Add(link); HtmlHead head = (HtmlHead)this.Page.FindControl("pageHead"); head.Controls.Add(lnk); End Sub </script>
Whats the error you are getting. Did you make sure that the name space 'System.Web.UI.HtmlControls' is added to your applications configuration file?