Saturday, September 8, 2012

How to Enable jQuery Intellisense in Visual Studio 2010 ?

How to Do That ?

There are 2 ways to do that.

Method 1 :

When you are working with Local copy of js files,Then you have to set up jquery-1.5.1-vsdoc.js file as below.(This is my js file version.It supports These versions )

Local copy of js files

Then on Master Page Set Script Tags like below.
<head>
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
</head>

After that on Child Pages you can have Jquery Intellisense on each level of your code as below.

Jquery Intellisense


Method 2 :

If you are referring js files from CDN (Content Delivery Network) then add vsdoc.js file into your Scripts folder  like below.

CDN (Content Delivery Network)

Your Master Page should looks like below.
                                      with  Microsoft CDN 
<head>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.7.1.min.js" type="text/javascript">
</script>
</head>
                                       with Google CDN

<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript">
</script>
</head>


Note : If you set up vsdoc.js file as above then it works with both CDN.

Conclusion

By using above methods you can use jQuery Intellisense with VS 2010.One Very Important thing you have to remember here is both your .min.js file and .vsdoc.js files Versions Must be the Same.Otherwise some wrong Intellisense information may appear for Jquery functions.

Happy Coding.

May Be Use Full To You :
How to Disable a Button Using Jquery and CSS ?
How to Convert Linq Entity Query into T-SQL ?
How to Improve Performance of Entity Framework Query (over 400 times)?

5 comments:

  1. well if you working with ASP.Net MVC you can add the reference to Layout File or your master page. Just drag the file from your solution explorer and drop it on the above mentioned location it should just work for you.

    -- atul chaudhary --

    ReplyDelete
    Replies
    1. Yes.Its working here I have mentioned how to work with CDN also.Any way Thanks for your comment.

      Delete
  2. Thanks , this is right way...........

    ReplyDelete
    Replies
    1. Thanks Yashwant, I’m glad you found it useful !

      Delete

Thanks for your Feedback.