我想创建一个自定义数据注释,强制输入的数据为大写。如果用户以小写形式键入内容,则应自动(并且静默地)将其转换为大写。这不是验证问题。
我想要这样的东西:
public class Address {
public string Address {get; set;}
public string City {get; set;}
[ForceUpperCase]
public string State{get; set;}
}
例如,当使用 @HTML.EditorFor(x => x.State) 我希望创建的 HTML 可以为我处理所有这些 - 我不想编写 jQuery 调用来更改数据或强制使用特定的类名。