Whenever I try to run a page with a stylesheet link in it, I get an error that says you need runat="server" in the head tag.
So I found this and tried it in the Page_Load event
But when I run it it saysCode:HtmlLink fred = new HtmlLink(); fred.Href = "Stylesheet.css"; fred.Attributes.Add("rel", "stylesheet"); fred.Attributes.Add("type", "text/css"); Page.Header.Controls.Add(fred);
Object reference not set to an instance of an object.
Why? When I am typing it intellisense fills it all in. I have used the 'new' keyword. What is wrong?
Thanks for any help.




Reply With Quote