仅针对第一个元素进行远程验证。对于其他元素,null值包含在参数中,因此不会进行验证。为什么它为其余行传递空值?仅传递第0行值。我究竟做错了什么?或者可以选择进行验证吗?
我的模特:
public class AdminModel
{
....
public List<Detail> ManageDetails { get; set; }
}
public class Detail
{
public string Id { get; set; }
[Remote("CheckValidity", "", AdditionalFields = "InDate, OutDate", ErrorMessage = "Time is invalid.")]
public string InTime { get; set; }
}
使用for循环渲染视图:
@for (int index = 0; index < Model.ManageDetails.Count; index++)
{
@Html.HiddenFor(model => model.ManageDetails[index].Id)
@Html.TextBoxFor(model => model.ManageDetails[index].InTime})
@Html.ValidationMessageFor(model => model.ManageDertails[index].InTime)
}