Microsoft integrated jquery intelliisense into Visual Studio

Source: Internet
Author: User

[Original address]Http://blog.joycode.com/scottgu/archive/2008/11/22/115357.aspx

Last month, I announced in my blog that Microsoft will support jquery. In the past few weeks, we have worked with the jquery development team to provide excellent support for jquery intelliisense in studio 2008 and Visual Web Developer 2008 Express (free of charge. Now this support can be downloaded and used.

To enable jquery intelliisense in vs 2008

To enable jquery's intelliisense in Vs, follow these three steps:

Step 1: Install vs 2008 SP1

Vs 2008 SP1 adds richer JavaScript intelliisense support to Visual Studio, and adds a lot of JavaScript LibrariesCodeComplete the support.

You can download vs 2008 SP1 and Visual Web Developer 2008 express SP1 here.

Step 2: Install vs 2008 patch kb958502 to support the "-vsdoc. js" intelliisense File

2
A patch was released a week ago and you can apply it to vs 2008 SP1 and vWD 2008 Express.
In SP1, this patch causes visual
When a javascript library is referenced, studio checks whether an optional "-vsdoc. js" file exists. If yes, it is used to drive
Javascript intelliisense engine.

The "-vsdoc. the JS file can contain XML comments for help documents on Javascript methods, and other code intelliisense prompts for dynamic JavaScript signatures that cannot be automatically inferred. You can learn more about the patch here. You can download the patch for free here.

Step 3: Download The jQuery-vsdoc.js File

We collaborated with the jquery development team to write a jQuery-vsdoc.js file that provides help comments and support for the Javascript intelliisense of the concatenating jquery selector method. You can download the jquery and jquery-vsdoc files on the official download page of jquery.com:

Save the jquery-vsdoc.js to the same directory where the jquery. js file in your project is located (check that its naming prefix matches the jquery file name ):

Then you can reference the standard jquery file through an HTML <script/> element like this:

You can also use the <asp: scriptmanager/> Control to reference it, or add a // <reference/> comment on the top of a separate. js file to reference it:

After that, Vs will find a-vsdoc. js file in the same directory where the referenced script file is located. If it is found, it will be used for help and intelliisense.

For example, we can use jquery to make a json-based GET request to obtain the intelliisense (after $.) of this method ):

And $. getjson () method parameter help/intelliisense:

 

If you nest a callback function in a method call, intelliisense will still work. For example, we may want to iterate every JSON object returned from the server:

For each item, we can execute another nested callback function:

We can use the each callback function to dynamically append a new image to the list (the src attribute of the image will point to the URL of the returned JSON media image ):

Then, on each dynamically generated image, we can connect to a click event processing function, which disappears through the animation effect when clicked:

Note that jquery intelliisense prompts very cleanly at every level of our code.

Tips and tricks for JavaScript intelliisense

Jeff king from the web tool development team wrote a great post earlier this week to answer several common questions about how JavaScript intelliisense works in vs 2008, I highly recommend that you read this article.

He
One trick (here I want to demonstrate) is to use JavaScript in the user control/section (. ascx file)
A technology that can be used when intelliisense is used. Often, you do not want to include the <script
Src = ""/>
References, which often exist on the master page or content page that uses the user control. Of course, the problem is that, by default, vs cannot know that this script is used in the user control.
Therefore, it does not provide you with intelliisense.

One way to enable intelliisense is to add the <SCRIPT src = ""/> element to your user control, but add a server <% if %> block around it, the value is always false at runtime:

ASP. NET does not display the script identifier at runtime (because it is contained in an if block that is always false). HoweverBut yesCalculate the <script/> identifier and provide the intelliisense for it in the user control. This is a very useful technology in scenarios such as user controls. Jeff has more details in his FAQ posts and the original jquery intelliisense posts. Rick Strahl also has a good post here about using jquery intelliisense.

More information

To learn more about jquery, I suggest you watch the ASP. NET and jquery lectures by Stephen Walther at the PDC Conference. Click here to download his code routines and PowerPoint handouts.

Rick Strahl also has a great article about introduction to jquery, discussing how to use jquery in ASP. NET. Karl Seguin has two excellent basic jquery tutorials here, which provides a brief overview of how to use jquery.

I also highly recommend jquery in action.

I hope this article will help you,

Scott

Tags: ASP. NET, Visual Studio,. net, Atlas, community news

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.