0

我有一个带有文本框、提交按钮、下拉列表的表单.....我<%Html.EnableClientValidation(); %>用来验证表单中的所有元素。但问题是当我写<% using (Html.BeginForm()){ }%>的时候,验证工作,但是当我点击提交按钮时,即使我完成了每个元素的所有条件,它什么也没做。并且提交按钮正在提交,而我使用<form method="post">而不是<% using (Html.BeginForm()){ }%>.

我在我的视图中使用 jquery 选项卡,所以我有多个提交按钮来执行不同的任务(我在控制器中测试提交按钮的值)。 这是我的看法

谁能告诉我,我在这里做错了什么?

先谢谢了。

4

1 回答 1

0

I'd make sure that you wrap your entire form in the braces when using the <% using (Html.BeginForm()){ }%>. If your submit button is not contained within those braces, then it will not cause the form to post.

<% using(Html.BeginForm()) { %>

... form elements here ...

<% } %>

When you use this method, remove the other form tags on the page as this syntax is equivalent to writing:

    <form>

    ... form elements here ...

    </form>
于 2012-08-13T10:18:57.220 回答