I am using asp.NET with masterpages and usercontrols.
In MasterPage:
Doing
<link href='<%=ResolveUrl("~/path/file.css")%>' rel="stylesheet" type="text/css" />
will not work and the css will not load
BUT
Doing
<link runat="server" href='~/path/file.css' rel="stylesheet" type="text/css" />
will work and the css will load
In User Control:
Doing
<link runat="server" href='~/path/file.css' rel="stylesheet" type="text/css" />
will not work and the css will not load
BUT
Doing
<link href='<%=ResolveUrl("~/path/file.css")%>' rel="stylesheet" type="text/css" />
will work and the css will load
In master page ResolveUrl doesn’t work and runat=”server” works where in user control the opposite is the true. Maybe I worng and I appriciate if someone will check this. If this is the situation, what is the reason for this inconsistency?
Ok, I got it.
In one of the cases I had
<head runat="server">tag. Because the runat=”server”, the ResolveUrl is not act as a server method but a simple text. That is why ResolveUrl didn’t word – I had runat=”server” in the head tag.