我将 List 从 Model 传递到 view ,所以我在 view 中指定了这个 IEnumerable。在这种情况下,客户端验证不会触发
看法 :
@model IEnumerable<ShoppingCart.Models.ShoppingClass>
@{
ViewBag.Title = "Display";
}
<script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
@Html.ValidationSummary(true)
@using (Html.BeginForm())
{
<table>
<tr>
<td>@Html.Label("BrandName")
</td>
<td>@Html.TextBox("BrandName")
<div>
@Html.ValidationMessage("BrandName")</div>
</td>
<td>
<input type="submit" value="Search" name="Search" />
</td>
</tr>
</table>
}