views:

100

answers:

3

Other than the "if(false)" hack, is there any way to get Intellisense working in VS 2010 / MVC when using the server-side Url.Content() method for re-basing Javascript files?

Master Page:

<script src="<%=Url.Content("~/Scripts/jquery-1.4.2.js") %>" type="text/javascript"></script>

I know about the if(false) hack but I was hoping there way a more elegant solution.

if(false) hack:

<% if (false){ %>
 <script type="text/javascript" src="../Scripts/jquery-1.4.2.js"></script>
<% } %>

Does Microsoft have any plans to address this issue in future releases of VS?

A: 

I guess even Visual Studio's Intellisense is not comfortable with the tag soup :-) Not really answering your question but you could use MVCContrib:

<%= Html.ScriptInclude("~/scripts/jquery-1.4.2.js") %>
Darin Dimitrov
+1  A: 

I find the best approach is to keep your JavaScript in separate files, particularly when you're working mostly event driven with jQuery. That way you can reference your related files to get full intellisense support and get all the browser-caching advantages that come with this approach.

pdr
A: 

you can drag the .js file from solution explorer to code window which generates the following line: /// <reference path="jquery-1.4.1-vsdoc.js" /> it works well in custom JS files that rely on other JS files (in my case jquery is included in the master page).

If you are having trouble in the aspx content files - I am using T4MVC; I have <script src="<%: Links.Scripts.jquery_1_4_1_js %>" type="text/javascript"></script> and I get Intellisense there as well...

Felix