本文介绍了禁用客户端验证在MVC 3英寸取消]提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OK,一直想事情小时,可以使用一些帮助。我想在MVC 3有后退和下一个按钮来实现的页面。当单击后退按钮我想从运行,这样,我的操作方法将运行,并且用户发送到previous逻辑网页禁用客户端MVC验证。我试过这样:

OK, been trying things for hours and could use some help. I'm trying to implement a page in MVC 3 that has "back" and "next" buttons. When the back button is clicked I want to disable client-side MVC validation from running so that my action method will run and send the user to the previous logical web page. I've tried this:

<script type="text/javascript">
  document.getElementById("backButton").disableValidation = true;
</script>

和这样的:

<input type="submit" name="backButton" value="← Back"
 title="Go back to step 1." disableValidation="true" />

但无论怎样,在cilent端验证的JavaScript踢,不会让按钮做它的后背部。我在想, disableValidation 只能在MVC 2也许和我应该做的东西在MVC 3人,但似乎无法找到任何的例子。

But no matter what, the cilent-side validation JavaScript kicks in and won't let the button do its post-back. I'm thinking that disableValidation only works in MVC 2 perhaps, and I'm supposed to be doing something else in MVC 3, but cannot seem to find any examples.

推荐答案

这是什么神奇的力量,导致了答案,你张贴问题的地方要尽快揭示出来?

What is this mystical force that causes the answer to reveal itself as soon as you post a question somewhere?

它看起来像在MVC 3通过添加类取消它上的一个按钮关闭客户端验证。所以在我的例子:

It looks like in MVC 3 you disable client-side validation on a button by adding the class "cancel" to it. So in my example:

<input type="submit" name="backButton" value="← Back"
 title="Go back to step 1." class="cancel" />

伟大工程。它或者是不需要ID属性。如果您在按钮上有一个实际的样式类,只是这样做:

works great. And no ID attribute is needed either. If you have an actual style class on the button, just do this:

<input type="submit" name="backButton" value="← Back"
 title="Go back to step 1." class="style-name cancel" />

这篇关于禁用客户端验证在MVC 3英寸取消]提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 09:54