In the MVC project, the solution is to use the URL. Content Method to reference the jquery file and then intelligently prompt failure.

Source: Internet
Author: User

I don't know how to write this title, but I hope the content of this article will help you.

 

The scenario is as follows:

Jquery is often referenced when we use development programs. However, due to the routing relationship, the address of the final access page is not fixed relative to the JS file.

To reference jquery files in the view, we usually use the following code:

<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>

There is no problem with running the program, but there is a new problem, that is, when we write js code in the view, there is no jquery smart prompt.

This is really an annoying question.

 

The following are the solutions I have come up:

Add such code to the view page

1 @if (false)2 {3     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>4 }

Then press Ctrl + Shift + J to update JScript intelliisense

Oh, try again now, and the long-time intelligent prompt is coming out.

 

Then, use the plug-in code segment function (SNIPPET) in Vs and set a shortcut key to quickly Insert the code.

This method can be used in different pages of.

You can handle smart prompts for other JS files.

Below is my snippet file, JQ. snippet

You can modify it in the past.

<Codesnippet format = "1.1.0" xmlns = "http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> 

Then, store it in the Directory D: \ My database \ Documents ents \ Visual Studio 2010 \ code snippets \ Visual Web Developer \ My HTML snippets.

(The specific directory depends on your system)

 

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.