How do I turn off client side validation in MVC 3?

2019-02-26 21:06发布

I have a framework for client side validation that I'd prefer to use over the existing one that ships with ASP.NET MVC 3.

Does anyone know how to disable it in MVC 3?

I have tried the following:

HtmlHelper.ClientValidationEnabled = false;
HtmlHelper.UnobtrusiveJavaScriptEnabled = false;

And this in the web.config:

<configuration>
  <appSettings>
    <add key="ClientValidationEnabled" value="false"/> 
    <add key="UnobtrusiveJavaScriptEnabled" value="false"/> 
  </appSettings>
</configuration>

Neither have worked :(

3条回答
够拽才男人
2楼-- · 2019-02-26 21:28

enable unobtrusive and disable clientvalidation.

<configuration>
  <appSettings>
    <add key="ClientValidationEnabled" value="false"/> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/> 
  </appSettings>
</configuration>

I just tried it (actually with both false) and it works fine. Its possible your page was being cached as well. I recommend keeping UnobtrusiveJavaScriptEnabled=true because of the lighter ajax attributes it adds.

查看更多
Emotional °昔
3楼-- · 2019-02-26 21:32

For me it looks like the setting needed to be set in the base web.config. IT SEEMS TO BE IGNORED IF YOU TRY TO SET IT IN THE VIEW web.config FILE!

查看更多
我想做一个坏孩纸
4楼-- · 2019-02-26 21:46

Disable it in your web.config:

<appSettings>
  <add key="ClientValidationEnabled" value="false"/>
</appSettings>
查看更多
登录 后发表回答