I am using the following style for ensuring that whatever my current page URL, the required script files are always loaded, i.e. the correct URL is rendered.
<script src='<%= ResolveUrl("~/Scripts/jquery-1.4.1.js")%>' type="text/javascript" />
Yet when I try a similar approach with a stylesheet, as below, the actual code is rendered.
<link href='<%= ResolveUrl("~/Styles/Blueprint/src/reset.css") %>' rel="stylesheet" type="text/css" />
Why is this and how can I achieve what I am trying but failing to with the second example?
I have found the following approach to work well, and in my opinion it makes for a neater
<head>tag as well:Note the databinding expressions used instead of code render blocks. This is following the advice in Milan Negovan‘s Code Blocks Inside Master Pages Cause Trouble article, which very nicely deals with this strange problem.
NB: This approach does require the following minimum code behind for your master page: