【发布时间】:2012-12-29 15:39:37
【问题描述】:
我有一个 DropDownLists 的编辑器模板,它标有如下属性:
[AttributeUsage(AttributeTargets.Property)]
public class DropDownListAttribute : UIHintAttribute
{
public string SelectListName { get; set; }
public DropDownListAttribute(string selectListName)
: base("DropDownList", "MVC", selectListName)
{
SelectListName = selectListName;
}
}
而且它本身看起来是这样的:
@using Comair.RI.UI.Core
@{
var list = this.GetModelSelectList();
var listWithSelected = new SelectList(list.Items, list.DataValueField, list.DataTextField, Model);
}
@Html.DropDownListFor(m => Model, listWithSelected, " - select - ")
我的问题是它只验证服务器端,这对于用户解决所有客户端验证非常烦人,只是提交并获得一个新的、令人惊讶的服务器端验证。
【问题讨论】:
-
你能添加你的模型的代码
-
@SławomirRosiek 这应该是什么意思?这是适用于任何模型的一般问题。
-
对我来说它有效 - 您是否只对那个控件有问题,或者可能对所有客户端验证器有问题?
标签: asp.net-mvc asp.net-mvc-4 data-annotations asp.net-mvc-viewmodel