【发布时间】:2011-11-30 17:37:11
【问题描述】:
我的模特:
public class EntryModel
{
[Required]
public string Date { get; set; }
public string Car { get; set; }
public string Engine { get; set; }
public string User { get; set; }
public int CarCod { get; set; }
public int EngineCod { get; set; }
}
我的观点:
<%=Html.Label("Car")%>
<%=Html.Text("Car", car,new { @class = js_car")%>
<%=Html.ValidationMessageFor(x=>x.Car) %>
<%=Html.TextBox("CarCod", carCod, new { @class = "js_car", @style = "display:none;",@id="_car_cod" })%>
我的问题:
发布数据时,“CarCod”总是在 ModelState 上引发错误,从而使 ModelState.IsValid 和 Html.ValidationSummary 都无用。
我已经有解决方法(即不使用它们),但很高兴知道原因。
【问题讨论】:
标签: c# asp.net-mvc validation asp.net-mvc-2