比方说,我有一个视图模型下面的选择列表的(国家):ASP.NET MVC 2验证的SelectList
//..
private static string[] _countries = new[] {
"USA",
"Canada",
"Japan"
};
//...
SelectList Countries = new SelectList(_countries, dinner.Country);
//...
我呈现以下流行的下拉列表:
<%: Html.DropDownListFor(m => m.Dinner.Country, Model.Countries) %>
我注意到使用Firebug,我可以将自己的值注入DropDownList,并将该值插入到数据库中。
验证没有注入值(最好是DRY方法)的最佳方法是什么?
谢谢,这是我正在寻找的答案。 MVC 2特定(注释)而不是一般(布尔方法)。 – KPthunder 2010-08-15 05:10:21