Rokal
Rokal

Reputation: 485

Is there any way to get Intellisense working in Visual Studio / MVC without the "if(false)" hack?

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?

Upvotes: 4

Views: 356

Answers (4)

Felix
Felix

Reputation: 10078

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...

Upvotes: 1

pdr
pdr

Reputation: 6440

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.

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1039328

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") %>

Upvotes: 0

Related Questions