我有一个属性DepartmentId的必需注释,然后我创建这样的视图,“form1”显示消息,我必须选择,但“form2”没有做任何事情并提交,如果我删除“form1”,“form2”会正常工作。有没有办法制作" form2"验证,谢谢。
<form method="post" name="form1">
@Html.DropDownList("DepartmentId",
new SelectList(departments, "Id", "Name"),
"Select Gender",
new { @class = "form-control" })
@Html.ValidationMessageFor(x => x.DepartmentId)
<button>Submit</button>
</form>
<form method="post" name="form2">
@Html.DropDownList("DepartmentId ",
new SelectList(departments, "Id", "Name"),
"Select Gender",
new { @class = "form-control" })
@Html.ValidationMessageFor(x => x.DepartmentId)
<button>Submit</button>
</form>