通常为 ASP.NET MVC 3 Membership 生成的代码,尤其是NewPassword
类的属性ChangePasswordModel
大致如下所示:
[Required]
[StringLength(100, MinimumLength=6)]
[DataType(DataType.Password)]
[Display("Name = CurrentPassword")]
public string NewPassword { get; set; }
为了用我正在使用的外部参数填充一些信息RecourceType:
(在这种情况下,我正在更改并使用来自资源的一些附加数据OldPassword
填充属性Display
[Required]
[DataType(DataType.Password)]
[Display(ResourceType = typeof(Account), Name = "ChangePasswordCurrent")]
public string OldPassword { get; set; }
回到NewPassword
。我怎样才能用MinimumLenght
with代替Membership.MinRequiredPasswordLength
?:我的尝试:
[Required]
[StringLength(100, MinimumLength=Membership.MinRequiredPasswordLength)]
[DataType(DataType.Password)]
[Display(ResourceType=typeof(Account), Name= "ChangePasswordNew")]
public string NewPassword { get; set; }
这会产生错误:
属性参数必须是属性参数类型的常量表达式、typeof 表达式或数组创建表达式 ( http://msdn.microsoft.com/de-de/library/09ze6t76%28v=vs.90%29.aspx )