如何解决C# ASP.NET MVC 显示属性通过 Resources.resx 提示文件
[display(ResourceType = typeof(Properties.Resources),Prompt = "What should be here?")]
[required(ErrorMessageResourceType = typeof(Properties.ResourcesDataAnnotations),ErrorMessageResourceName = "IDrequired")]
[RegularExpression(@"[0-9]{9}",ErrorMessageResourceType = typeof(Properties.ResourcesDataAnnotations),ErrorMessageResourceName = "IDNotValid")]
public override string ID { get => base.ID; set => base.ID = value; }
解决方法
像评论中提到的寒鸦一样使用
[Display(ResourceType = typeof(Properties.Resources),Prompt = "IDPrompt")]
[Required(ErrorMessageResourceType = typeof(Properties.ResourcesDataAnnotations),ErrorMessageResourceName = "IDRequired")]
[RegularExpression(@"[0-9]{9}",ErrorMessageResourceType = typeof(Properties.ResourcesDataAnnotations),ErrorMessageResourceName = "IDNotValid")]
public override string ID { get => base.ID; set => base.ID = value; }
其中 IDPrompt 是 Resources.resx 文件中的静态字符串名称。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。