Click here to Skip to main content
Click here to Skip to main content

Tagged as

How to fix Visual Studio 2008 Intellisense for JQuery 1.6.1

, 24 Jun 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
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:

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

1505: "triggered": };

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

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:

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:

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:

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

/// <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)

Share

About the Author

Massimiliano Giustizieri
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 Pinmemberrahkan4-Aug-11 10:05 
GeneralRe: didn't completely work for me PinmemberMassimiliano Giustizieri16-Aug-11 15:58 
You didn't need to change that file. You should have followed the procedure just as described in the article. Indeed you said that it was working great in the first moment. However ... glad the article was helpful for you to find a solution in any case.
Thanks for reading!
QuestionExcellent, thank you. PinmemberShellySS12-Jul-11 6:30 
AnswerRe: Excellent, thank you. PinmemberMassimiliano Giustizieri12-Jul-11 7:01 
AnswerFaster way to fix the problem... PinmemberGary Noter28-Jun-11 7:42 
GeneralRe: Faster way to fix the problem... PinmemberMassimiliano Giustizieri28-Jun-11 7:46 
QuestionFormatting PinmvpRichard MacCutchan24-Jun-11 4:26 
AnswerRe: Formatting PinmemberMassimiliano Giustizieri24-Jun-11 4:29 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 24 Jun 2011
Article Copyright 2011 by Massimiliano Giustizieri
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid