简体   繁体   English

将jquery验证插件添加到asp.net 4.5

[英]Add jquery validation plugin to asp.net 4.5

I see that asp.net (framework 4.5) uses the 我看到asp.net(框架4.5)使用了

       <asp:ScriptReference>

tags to include the bundles for jquery and jqueryUI etc. But if i want to add a Jquery Validation plugin , how do i add that to my Site.Master page? 标签以包含jquery和jqueryUI等的捆绑包。但是,如果我想添加Jquery Validation插件,如何将其添加到我的Site.Master页面?

I cannot add it inside the tags, because as at that point other main jquery scripts did not get added yet. 我无法将其添加到标签中,因为到那时还没有添加其他主要的jquery脚本。

Thanks. 谢谢。

Found the solution by reading about bundling and minification 通过阅读有关捆绑和缩小的内容找到解决方案

Under the App_Start folder add the following to the BundleConfig.cs 在App_Start文件夹下,将以下内容添加到BundleConfig.cs中

   bundles.Add(new ScriptBundle("~/bundles/jqueryVal").Include(
                                "~/Scripts/jquery.validate.js",);

Then in the Site.Master right after the end of ScriptReference Tags add the following 然后在ScriptReference标签结束后的Site.Master中添加以下内容

     <asp:PlaceHolder runat="server">
           <%: Scripts.Render("~/bundles/jqueryVal") %>
     </asp:PlaceHolder>

That worked for me. 那对我有用。 I used this link for reference. 我使用此链接作为参考。

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

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