Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc MVC4 C#多表单一页验证_Asp.net Mvc_Templates_Entity Framework 4_Html Helper - Fatal编程技术网

Asp.net mvc MVC4 C#多表单一页验证

Asp.net mvc MVC4 C#多表单一页验证,asp.net-mvc,templates,entity-framework-4,html-helper,Asp.net Mvc,Templates,Entity Framework 4,Html Helper,我在mvc项目的一个视图上有3个表单,如下“ 视图: 存款 @LabelFor(u=>u.AccountNumber1) @Html.DropDownList(“帐户”,“选择帐户--”) @LabelFor(u=>u.Amount) @TextBoxFor(u=>u.Amount,新的{style=“width:150px”}) @Html.ValidationMessageFor(u=>u.Amount) @LabelFor(u=>u.Comment) @TextAreaFor(u=>u.

我在mvc项目的一个视图上有3个表单,如下“

视图:


存款
@LabelFor(u=>u.AccountNumber1)
@Html.DropDownList(“帐户”,“选择帐户--”)
@LabelFor(u=>u.Amount)
@TextBoxFor(u=>u.Amount,新的{style=“width:150px”})
@Html.ValidationMessageFor(u=>u.Amount)
@LabelFor(u=>u.Comment)
@TextAreaFor(u=>u.Comment,新的{style=“width:250px”})
@Html.ValidationMessageFor(u=>u.Comment)
}
@使用(Html.BeginForm(“取款”、“ATM”、FormMethod.Post、new{}))
{
@ValidationSummary(true,“存款失败,请检查您的详细信息”);
取款
@LabelFor(u=>u.AccountNumber1)
@Html.DropDownList(“帐户”,“选择帐户--”)
@LabelFor(u=>u.Amount)
@TextBoxFor(u=>u.Amount,新的{style=“width:150px”})
@Html.ValidationMessageFor(u=>u.Amount)
@LabelFor(u=>u.Comment)
@TextAreaFor(u=>u.Comment,新的{style=“width:250px”})
@Html.ValidationMessageFor(u=>u.Comment)
}
@使用(Html.BeginForm(“Transfer”,“ATM”,FormMethod.Post,new{}))
{
@ValidationSummary(true,“存款失败,请检查您的详细信息”);
转账
@LabelFor(u=>u.AccountNumber1)
@Html.DropDownList(“帐户”,“选择帐户--”)
@LabelFor(u=>u.AccountNumber2)
@Html.DropDownList(“帐户”,“选择帐户--”)
@LabelFor(u=>u.Amount)
@TextBoxFor(u=>u.Amount,新的{style=“width:150px”})
@Html.ValidationMessageFor(u=>u.Amount)
@LabelFor(u=>u.Comment)
@TextAreaFor(u=>u.Comment,新的{style=“width:250px”})
@Html.ValidationMessageFor(u=>u.Comment)
}
在我的控制器中,我正在处理上述每个功能

但是,当其中一个表单出现错误时(即空白字段) 所有表单上都会显示错误(validationSummary)


如何为每个表单生成两个错误?

考虑为每个表单使用局部视图,并使用调用主视图中的局部视图

@Html.Partial("PartialViewName")

本教程将为您提供有关局部视图的一些基本概念,非常抱歉,但没有帮助,是否有其他方法解决此问题?不确定是否可以,这是一个解决方法,请查看更多信息,这可能会在此处看到我的答案
@Html.Partial("PartialViewName")