【发布时间】:2013-01-24 03:09:29
【问题描述】:
我无法执行依赖于另一个字段的数据类型验证。我在这里找到的大多数示例都是基于另一个字段的值来确定是否需要某个字段(仅当IsMarried 是true 时才需要MaidenName)。
我的模特
public class AttributeValuesModel
{
public IList<AttributeModel> Values {get; set;}
}
public class AttributeModel
{
[Required]
public string AttributeName {get; set;}
[Required]
public string AttributeValue {get; set;}
[Required]
public int DataTypeId {get; set;}
}
我想做的是根据 DataTypeId 的值验证 AttributeValue 的用户输入。为了清楚起见,DataTypeId 的值在我向用户展示视图之前就已经知道了。
//Possible values for DataTypeId are
//1 for decimal
//2 for dates
//3 for integer
这可能吗?
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-3 razor entity-attribute-value