Click here to Skip to main content
15,881,172 members
Articles / Web Development / ASP.NET

How to fix Visual Studio 2008 Intellisense for JQuery 1.6.1

Rate me:
Please Sign up or sign in to vote.
4.30/5 (7 votes)
24 Jun 2011CPOL5 min read 39.6K   543   10   8
This article shows how to fix the error “Error updating JScript IntelliSense” and restore full Intellisense support in your ASP.NET Web Applications that make use of JQuery 1.6.1
image007.jpg

Introduction

This article is the final product of hours and hours and hours of frustration due to the use of JQuery in a Web Application I was developing on my own in Visual Studio 2008. Visual Studio 2010 has a great JavaScript support but, until Visual Studio 2005 the attention for JavaScript was very poor. Visual Studio 2008 was yet a big step ahead, but the explosion of the JQuery library and the ease of deployment in almost any project has shown all the limitations of a platform that is starting to grow old. Although Visual Studio 2010 is a really good IDE, there are cases where you are tied to use version 2008, and this people is the target this article has been written for.

Searching for a solution to the infamous “Error updating JScript IntelliSense” problem will give you the bad sensation that at Microsoft they don't want to put too much of effort to guarantee the support for JQuery in Visual Studio 2008.

Moreover, the same JQuery website offers JQuery 1.4.1 as the last and most updated version of the library that is shipped with a documentation file associated. Most people on the forums will suggest you to both upgrade your IDE to Visual Studio 2010, or downgrade your JQuery to 1.4.1, which is also the last one that they guarantee to be tested and fully working in Visual Studio 2008. Well, know what? None of them can be accepted as a solution! There are changes and bug fixes from version 1.4.1 to version 1.6.1 that I want in my Web Application, and I’m going to show how you can circumnavigate this problem and leverage the full power of both JQuery 1.6.1 and the Visual Studio 2008 Intellisense.

Prerequisites

  • Visual Studio 2008
  • Visual Studio 2008 Service Pack 1
  • JScript Editor support for “-vsdoc.js” IntelliSense documentation files
  • JQuery 1.6.1 (last version at the time of writing) with documentation file

Reference Pages

Searching the Internet for “jquery-1.6.1-vsdoc.js” will bring you to the Microsoft Ajax Content Delivery Network page (http://www.asp.net/ajaxlibrary/cdn.ashx), which we will use as our reference page.

Here we can find everything we need. If you haven’t already done it, but I doubt, go and install as soon as possible the Visual Studio 2008 Service Pack 1. This will serve as a prerequisite for the hotfix KB958502 that we’ll install later.

image008.jpg

Installing the Service Pack 1 may even take a couple of hours, so be patient ... when finished also install the hotfix. This patch adds JScript Editor support for “-vsdoc.js” IntelliSense documentation files. When you’ll include one .js file in your project, Visual Studio 2008 will automatically see if there’s in the same folder a file with the same name but ending with “–vsdoc.js”. This file contains comments to the code, that are appropriately formatted to be used as Intellisense tooltips. We’re now ready to set up our project.

Setting Up a Solution

Create one blank Web Application. In our reference page, scroll down until you find the section where third party files are hosted through the Content Delivery Network. At the top of this section, you’ll find just all the JQuery files that we need. Copy the first 3 paths and download all three files in your project folder.

image009.jpg

After you’ve added your files to your project, you should be in this situation:

image011.jpg

Now take the file jquery-1.6.1.js (yes, the full one, NOT the minified) and drop it in the head section of the Default.aspx page. If you have done correctly, you’ll have:

ASP.NET
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.6.1.js" type="text/javascript"></script>
</head>

And after a couple of seconds .. ta-da ! Just the error we wanted to have !

image013.jpg 

After all, you can think that the –vsdoc.js file is just a documentation file. If we haven’t found a solution on the web, we can try and make the solution ourselves, and as long as we respect the JavaScript syntax we can type in it whatever we want to help the parser to read that file. Just don’t touch the comments!

The error reports some problem at line 1504 of the –vsdoc.js file. So let’s open that file and go to line 1504. We don’t find anything broken there, but we do find something at the next line, where there’s an undefined assignment that looks like this:

JavaScript
1505: "triggered": };

So let’s fix it and place an empty object just to calm down the JavaScript parser:

JavaScript
1505 "triggered": {} };

Now save, and hit CTRL + SHIFT + J to update the Jscript Intellisense. Cool! The error went away but a warning similar to the first one pops up:

image020.jpg 

This time, the error is at lines 2648 and 2649, so let’s go straight there in our –vsdoc.js file and indeed find something quite unusual:

JavaScript
2549 "checkClone": ,

There’s another undefined assignment there. While a modern browser’s JavaScript engine can handle that and live with such assignments, a parser that is meant to provide you code assistance may not like it very much, so let’s fix this also to:

JavaScript
2549 "checkClone": true,

Save again, and hit CTRL + SHIFT + J to update the Jscript Intellisense, again. If today is your lucky day (and you've crossed your fingers correctly) you’ll see “Ready” in the Visual Studio status bar, and no more errors in the Errors pane. Now remove the reference to jquery1.6.1.js that we have put in our Default.aspx page, and replace it with a reference to the minified version of JQuery that is surely the one that we’d like to eventually deploy. Your page should look like this in the head section, now:

HTML
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.6.1.min.js" type="text/javascript"></script> 
</head>

Now let’s add a new JavaScript file to our project, and at the very top of the file a commented reference to our –vsdoc.js documentation file, like this:

JavaScript
/// <reference path="jquery-1.6.1-vsdoc.js" />

Let’s try to type $ in the JavaScript file and ...

image021.jpg

Wow, the Intellisense is working … it looks promising! Try to type something more to see if the documentation has also been loaded:

image007.jpg 

Observe how Visual Studio 2008 is now able to offer a full Intellisense and method documentation support to JQuery 1.6.1!

Considerations

The only question to which I don’t have an answer is why Microsoft released a bugged documentation file for JQuery 1.6.1.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Exprivia
Italy Italy
I am 29 and I have a degree in Computer Science at the University of Bari (Italy) that I achieved with Full Marks and Honors.
My main fields of interest are in the world of Windows and the .NET framework.
I am currently employed as a Senior ASP.net and Sharepoint developer at Exprivia.
In the past I used to develop software in VC++, WPF/Silverlight, C#, and a number of other .NET related tecnologies.

Comments and Discussions

 
Suggestiondidn't completely work for me Pin
rahkan4-Aug-11 9:05
rahkan4-Aug-11 9:05 
GeneralRe: didn't completely work for me Pin
Massimiliano Giustizieri16-Aug-11 14:58
Massimiliano Giustizieri16-Aug-11 14:58 
QuestionExcellent, thank you. Pin
Shelly Skeens12-Jul-11 5:30
Shelly Skeens12-Jul-11 5:30 
AnswerRe: Excellent, thank you. Pin
Massimiliano Giustizieri12-Jul-11 6:01
Massimiliano Giustizieri12-Jul-11 6:01 
AnswerFaster way to fix the problem... Pin
MacSpudster28-Jun-11 6:42
professionalMacSpudster28-Jun-11 6:42 
GeneralRe: Faster way to fix the problem... Pin
Massimiliano Giustizieri28-Jun-11 6:46
Massimiliano Giustizieri28-Jun-11 6:46 
QuestionFormatting Pin
Richard MacCutchan24-Jun-11 3:26
mveRichard MacCutchan24-Jun-11 3:26 
AnswerRe: Formatting Pin
Massimiliano Giustizieri24-Jun-11 3:29
Massimiliano Giustizieri24-Jun-11 3:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.