I am using Visual Studio 2010 / ASP.net MVC 3 with the Razor View Engine. I created a new Project with the Internet Application template. What do I need to do to get Intellisens
From http://blog.meidianto.com/2010/05/13/vs2010-tips-7-how-to-make-jquery-intellisense-work-for-external-javascript-file/
Drag the jquery file into the js file you want intellisense on like this:
Then it will work like this:
If that's jQuery specific as the title specifies, trying adding line to the tag in the Views/Shared/_layout.cshtml
(or .vbhtml
) file:
@if (false) { <script src="../../Scripts/jquery-1.4.4-vsdoc.js" type="text/javascript"></script> }
This will reference the intellisense file to VisualStudio and still will not reference it in runtime.
Just remember, point to the vsdoc file relatively to the file you put this code in. Any code like ~
/Url.Content()
or any other runtime code will not be visible to VS for intellisense.
That's exactly why if (false)
hides the script reference from runtime (the if
block isn't executed), but doesn't hide it from VS intellisense (and provide another reference using Url.Content()
or so to the .min.js file).
I found good explanation which worked for me at: http://theycallmemrjames.blogspot.com/2011/03/jquery-intellisense-with-aspnet-mvc-and.html
These lines:
@if (false)
{
<script src="../../Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui.min.js" type="text/javascript"></script>
}
should be added to every view (where intellisense is needed). This will enable intellisense but will not add the second reference at runtime.
Seems for me in Vs2012 with a _layout.cshtml that the solution from @Mohamed Meligy doesn't help in views using that layout file. Maybe I'm missing something?
However - the solution here which seems to be recommended approach seems to work a treat and now I have intellisense for all references to all files I add references to in _references.js and don't need the runtime false trick bit, and can keep the views totally clean of references.