Jeff King, Program Manager for Visual Studio Web Tools blogged VS2008 SP1 Hotfix to Support “-vsdoc.js” IntelliSense Doc Files on Friday. The HotFix (VS2008 SP1 only) allows Visual Studio to find “-vsdoc.js” files that have commenting for IntelliSense in the same folder as a script file linked to from your document. In this post I am going to show you how to get IntelliSense working once the HotFix is installed in both a normal aspx page as well as an ASP.NET MasterPage.
So if you just link to the jquery-1.2.6.js file like below, Visual Studio will find the jquery-1.2.6-vsdoc.js file that is in the same folder and use it for IntelliSense.
Markup from head of Standard aspx page:
What if you want IntelliSense and you link to the jQuery file from an ASP.NET MasterPage though? Well, the best I can figure you still have to hack things a little as Visual Studio will not provide IntelliSense in your child pages in this situation. Follow the code below for a workaround.
Markup from MasterPage:
Notice that I am using databinding when resolving the path of the jQuery file. See this post for an explanation. Also notice I am linking to the minified file.
Markup from child aspx page:
By using the script tag hack, Visual Studio will find the file to use for IntelliSense, however when the page is rendered the script evaluates to false and the jQuery file from the MasterPage is not overridden. This method works well unless of course you need to debug the jQuery file. In that case, just switch the file linked to in the MasterPage to the non minified version. This method is nice though because you don’t end up forgetting to switch to the minified file when you deploy.
Please let me know in the comments if you find or know of a better way.