views:

148

answers:

3

A very basic question.

I have just installed Visual Studio 2008 Express Edition and was was going to make some use of jQuery.

I heard that jQuery is now supported by Visual Studio, but my question is.

What do I need to do to use it? Is is already included in the VS installation or do I need to download it separately and reference the downloaded library?

Thank you

A: 

ScottGu's blog is the place to go to find the answer to this question (and most other current Visual Studio questions for that matter)

Matthew Steeples
Thanks for the link but I have seen that post already. I was wondering if anything has changed since especially that now the Web Platform Installer is available
padn
A: 

It is not included. You just add

<script type="text/javascript">
    // You may specify partial version numbers, such as "1" or "1.3",
    //  with the same result. Doing so will automatically load the 
    //  latest version matching that partial revision pattern 
    //  (i.e. both 1 and 1.3 would load 1.3.2 today).
    google.load("jquery", "1.2.6");

    google.setOnLoadCallback(function() {
        // Place init code here instead of $(document).ready()
    });
</script>

to your master page or individual pages if not using a master page.

dr
I think he's wanting the vsdoc version to get jQuery intellisense
palmsey
@palmsay - yes you are right. I believe the approach suggested by dr is great for deployed code, but I believe I would need my local copy for Intellisense and for working without Internet access
padn
There's a bit more to it than that...http://code.google.com/apis/ajax/documentation/
Michael Haren
+3  A: 

Download the Visual Studio version of jQuery (should have vsdoc in the name) here.

You can use this hotfix to have the vsdoc js files be automatically detected, or use this slightly hackish workaround:

For jQuery intellisense in an ASP.NET file:

<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<% if (false) { %}
  <script src="jquery-1.3.2-vsdoc.js" type="text/javascript"></script>
<% } %>

The "if (false)" bit ensures that the script won't ever actually be included, but intellisense will still pick up the reference.

For jQuery intellisense in another js file:

// <reference path="jquery-1.3.2-vsdoc.js" />
palmsey
Thanks palmsey. It looks that the hotfix is not needed anymore (probably already included). After downloading the jQuery I simply referenced it like <script src="javascript/jquery-1.3.2.js" type="text/javascript"></script> and the Intellisense works fine. see also http://blogs.msdn.com/webdevtools/archive/2008/10/28/rich-intellisense-for-jquery.aspx and http://blogs.msdn.com/webdevtools/archive/2008/11/07/hotfix-to-enable-vsdoc-js-intellisense-doc-files-is-now-available.aspx
padn