我工作的MVC 4项目,是不断显示即使在,做任何复杂类型的绑定验证或模型的简单GET方法ValidationMessage:
//location/{locationId}/announcement
[HttpGet]
public ActionResult LocationMakeAnnouncement(int locationId)
{
var pageViewModel = this.BuildLocationMakeAnnouncementViewModel(locationId);
return View(pageViewModel);
}
该BuildLocationMakeAnnouncementViewModel
只有建立起视图模型和不接触的ModelState。
然后在视图中我有:
<span class="errorArea">@Html.ValidationMessage("ProductText", " ", new { @class = "inputErrorIcon" })</span>
发射:
<span class="errorArea"><span class="field-validation-valid inputErrorIcon" data-valmsg-for="ProductText" data-valmsg-replace="false"> </span></span>
输出的ModelState表明,它没有任何错误
@ViewData.ModelState.Values.Any(x => x.Errors.Count >= 1)
为什么会ValidatioMessage输出的时候有没有错误?
有什么建议么?