asp.net-mvc – 在mvc中使用带有错误消息的资源
发布时间:2020-12-16 00:23:42 所属栏目:asp.Net 来源:网络整理
导读:我想从资源中获取错误消息。当我尝试下面的代码时,我接受该错误:“属性参数必须是一个常量表达式,typeof表达式或数组创建表达式的属性参数类型”我能做什么? public class UserLoginModel{ [Required(ErrorMessage =Resources.PageResources.enterYourEm
我想从资源中获取错误消息。当我尝试下面的代码时,我接受该错误:“属性参数必须是一个常量表达式,typeof表达式或数组创建表达式的属性参数类型”我能做什么?
public class UserLoginModel { [Required(ErrorMessage =Resources.PageResources.enterYourEmail)] public String Email{ get; set; } [Required(ErrorMessage =Resources.PageResources.enterPassword)] public String Password { get; set; } 解决方法
尝试这个
[Required(ErrorMessageResourceType = typeof(Resources.Resources),ErrorMessageResourceName = "enterYourEmail")] public String Email{ get; set; } [Required(ErrorMessageResourceType = typeof(Resources.Resources),ErrorMessageResourceName = "enterPassword")] public String Password { get; set; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 如何在aspx页面中显示pdf?
- 如何为部署到aws弹性beanstalk的ASP.NET应用程序设置应用程
- asp.net-mvc – 分页助手asp.net mvc
- asp.net – 具有管道模式=集成的IIS 7.0不会在ASP .NET中加
- asp.net-mvc – 从业务层使用邮件库
- 如何删除IIS自定义标头像X-Powered-By:ASP.NET从响应?
- asp.net – 在WebForms中调试时关闭捆绑/缩小
- asp.net-mvc-3 – 在ASP.NET MVC中本地化/翻译路由
- 缩小ASP.Net MVC应用程序的HTML输出
- asp.net – 如何从ReSharper中删除“使用目录”消息
推荐文章
站长推荐
- asp.net-mvc – 为什么Microsoft堆栈说成本高昂?
- asp.net – 如何在构建期间从Visual Studio调用a
- asp.net-mvc – 在Mvc中验证DateFormat
- 在ASP.NET MVC 3中以特定格式验证日期
- asp.net-mvc – 如何成功配置Common.Logging?
- kendo-ui – Kendo Grid的水平滚动
- asp.net – 如何捕获异常形式ObjectDataSource.U
- asp.net – 为什么removeServerHeader在Azure We
- asp.net – 未指定SMTP主机
- asp.net-mvc – 在操作之间传递参数
热点阅读