我有以下代码:
@Html.ValidationSummary(false)
@Html.ValidationSummary(true, "xxx")
@using (Ajax.BeginForm(
action,
"Menus",
null,
new AjaxOptions
{
UpdateTargetId = "update-message",
InsertionMode = InsertionMode.Replace,
HttpMethod = "POST",
OnSuccess = success
}, new { @id = "menuForm" }))
{
<dl>
<dt>@Html.LabelFor(model => model.Order)</dt>
<dd>@Html.TextBoxFor(model => model.Order)</dd>
<dd>@Html.ValidationMessageFor(model => model.Order)</dd>
</dl>
当我输入 999 的订单值时,我会立即获得客户端验证,在订单文本框之后显示一条错误消息。但是,Html.ValidationSummary 区域中没有显示任何内容。是否可以将其与客户端验证一起使用?
这是我的模型:
public class Menu
{
[Range(0, 99, ErrorMessage = "{0} must be between {1} and {2}")]
[DisplayName("Order")]
public int Order { get; set; }
我的网络配置:
<appSettings>
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>