简体   繁体   English

如何在Visual Studio 2013 MVC5中包含简洁的Javascript

[英]How to include Unobtrusive Javascript in Visual Studio 2013 MVC5

I was trying to do something similar as described in this website http://www.asp.net/mvc/overview/older-versions/creating-a-mvc-3-application-with-razor-and-unobtrusive-javascript where I perform remote validation. 我正在尝试做与此网站http://www.asp.net/mvc/overview/older-versions/creating-a-mvc-3-application-with-razor-and-unobtrusive-javascript中所述的类似操作,其中我执行远程验证。 I have turned on UnobtrusiveJavaScriptEnabled and ClientValidationEnabled. 我已打开UnobtrusiveJavaScriptEnabled和ClientValidationEnabled。 However, when I reach the following part of the code I cannot locate jquery.validate.min.js (locally) and jquery.validate.unobtrusive.min.js. 但是,当我到达代码的以下部分时,无法在本地找到jquery.validate.min.js和jquery.validate.unobtrusive.min.js。 I have updated to the latest jquery version with NuGet but these files are not found anywhere. 我已经使用NuGet更新到最新的jquery版本,但是在任何地方都找不到这些文件。 Is there something I need to do? 我需要做些什么吗? Am I missing something? 我想念什么吗? The instructions about adding remote validation always assume that these files are present. 有关添加远程验证的说明始终假定存在这些文件。

<head>
  <title>@View.Title</title>
  <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
  <script src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
  <script src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
  <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
</head>

You are referring to files on the net not on your local drive. 您指的是网络上的文件,而不是本地驱动器上的文件。 Solution: download the files from the url into the script folder of your project and retry. 解决方案:将文件从url下载到项目的脚本文件夹中,然后重试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM