我的模型:
public class ViewRequestModel
{
[Required(ErrorMessage = "some")]
[Display(Name = "some")]
public int RequestType { get; set; }
}
我的控制器:
[HttpPost]
[Authorize(Roles = "P")]
public PartialViewResult ViewRequests(ViewRequestModel model)
{
string vn = "";
switch (model.RequestType)
{
...
}
return PartialView(vn);
}
我的观点:
@{
var reqTypes = new List<ListItem> { new ListItem { Text = "t1", Value = "1" },
new ListItem { Text = "t2", Value = "2" },
new ListItem { Text = "t3", Value = "3" } };
}
@Html.DropDownListFor(model => model.RequestType, new SelectList(reqTypes), new { id = "ddlType" })
@Html.ValidationMessageFor(model => model.RequestType)
当我尝试发布我的表单时,jquery 验证会阻止它并显示错误The field RequestType must be a number
我的错在哪里?