See this post by Jeff King about how Visual Studio can find a javascript file using the intellisense: JScript IntelliSense FAQ .
In particular, reading point No. 4, third line:
Site-relative paths are paths of the form "/ folder / file" and are calculated from the base of your site ( http: // site / application / folder / file ). This approach is supported by ASP.NET Web Forms and ASP.NET MVC. However, it is not supported by Visual Studio. The reason is that Visual Studio does not always know the final deployed location of your site and therefore path resolution cannot be guaranteed. Given that we have quite a few people using the site-relative paths, we might consider creating an assumption that simply allows this type of path to the root of the project. Given the risk that your site works when itโs really not, I wanted to see how many people were supporting it.
Please note that "[Regarding Sites] is not supported by Visual Studio." I always use relative site paths for my javascript and css files, so the decision to get Visual Studio to find your javascript files is the same solution so that Visual Studio can find your css files:
<link href="/content/default.css" rel="stylesheet" type="text/css" /> <% if (false) {%> <link href="../../content/default.css" rel="stylesheet" type="text/css" /> <% } %>
And now Visual Studio can find the CSS file and check my CSS class names (and the Design View looks much better).
Wrote my blog here: Why doesn't Visual Studio resolve CSS class names?
-Jeff
Jeff widmer
source share