I have an ascx page on which I want to add a link to a css file.
For this I use :
<link href="myCSS.css" rel="Stylesheet" type="text/css" />
But it doesn't work.
I also try this on the code behind :
System.Web.UI.HtmlControls.HtmlLink link = new System.Web.UI.HtmlControls.HtmlLink();
link.Href = "myCSS.css";
link.Attributes.Add("rel", "stylesheet");
link.Attributes.Add("type", "text/css");
link.Attributes.Add("title", "Default");
this.Page.Header.Controls.Add(link);
And this :
System.Web.UI.HtmlControls.HtmlGenericControl myCss = new System.Web.UI.HtmlControls.HtmlGenericControl();
myCss.TagName = "link";
myCss.Attributes.Add("type", "text/css");
myCss.Attributes.Add("rel", "stylesheet");
myCss.Attributes.Add("href", ResolveUrl("myCSS.css"));
this.Page.Header.Controls.Add(myCss);
I put this ascx file on an aspx file which uses a masterpage, maybe the problem is here ?
EDIT
The problem is the intellisense see the file (because it show my CSS classes in the file), but it doesn't apply them on my ascx file.
runat="server"and it doesn't work too