ASP.Net 2012 Unobtrusive Validation with jQuery

后端 未结 12 1544
小蘑菇
小蘑菇 2020-11-27 04:11

I was playing with Visual Studio 2012 and I created an empty ASP.Net Web Application, when I tried to add the traditional validator controls to a n

12条回答
  •  死守一世寂寞
    2020-11-27 04:49

    This is the official Microsoft answer from the MS Connect forums. I am copying the relevant text below :-

    When targeting .NET 4.5 Unobtrusive Validation is enabled by default. You need to have jQuery in your project and have something like this in Global.asax to register jQuery properly:

    ScriptManager.ScriptResourceMapping.AddDefinition("jquery", 
        new ScriptResourceDefinition {
            Path = "~/scripts/jquery-1.4.1.min.js",
            DebugPath = "~/scripts/jquery-1.4.1.js",
            CdnPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.1.min.js",
            CdnDebugPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.1.js"
        });
    

    Replacing the version of jQuery with the version you are using.

    You can also disable this new feature in web.config by removing the following line:

    
    

提交回复
热议问题