模型:
[required(AllowEmptyStrings = false,ErrorMessage="Please enter student name.")] [StringLength(20,ErrorMessage="Student name cannot be over 20 characters long")] public string StudentName { get; set; }
视图:
@Html.ValidationMessageFor(m=>m.StudentName,new {@class = "validation"})
好像ValidationMessageFor没有这样的重载.我如何申请课程?
解决方法
我只是看了
this.
所以在你的情况下尝试:
@Html.ValidationMessageFor(m=>m.StudentName,""/* or null or what you want the error message to be */,new { @class = "validation" })