【发布时间】:2016-12-19 18:35:16
【问题描述】:
当我按下提交时,如何避免回发验证?按下提交时,页面重新加载/回发,然后它给了我验证错误。
@model X.Models.ModelVm
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Birthday, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Birthday, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Birthday, "", new { @class = "text-danger" })
</div>
</div>
.....
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Get data" class="btn btn-default"/>
</div>
</div>
</div>
}
我的视图模型:
[Required]
[DataType(DataType.DateTime)]
public DateTime Birthday { get; set; }
【问题讨论】:
标签: c# jquery asp.net-mvc