本文介绍了利用资源,在MVC中的错误信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从资源得到错误信息。当I C $ CS试图$下面我把这个错误:的属性参数必须是常量前pression,属性参数类型的typeof前pression或数组创建前pression我能怎么办?
公共类UserLoginModel{ [必需的(=的ErrorMessage Resources.PageResources.enterYourEmail) 公共字符串电子邮件{搞定;组; } [必需的(=的ErrorMessage Resources.PageResources.enterPassword) 公共字符串密码{搞定;组;}解决方案
试试这个
[必需的(ErrorMessageResourceType = typeof运算(Resources.Resources) ErrorMessageResourceName =enterYourEmail)] 公共字符串电子邮件{搞定;组; } [必填(ErrorMessageResourceType = typeof运算(Resources.Resources) ErrorMessageResourceName =enterPassword)] 公共字符串密码{搞定;组;I want to get error message from resources. When i tried codes below i take that error:"An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type" What can i do ?
public class UserLoginModel { [Required(ErrorMessage =Resources.PageResources.enterYourEmail)] public String Email{ get; set; } [Required(ErrorMessage =Resources.PageResources.enterPassword)] public String Password { get; set; }解决方案
Try this
[Required(ErrorMessageResourceType = typeof(Resources.Resources), ErrorMessageResourceName = "enterYourEmail")] public String Email{ get; set; } [Required(ErrorMessageResourceType = typeof(Resources.Resources), ErrorMessageResourceName = "enterPassword")] public String Password { get; set;
更多推荐
利用资源,在MVC中的错误信息
发布评论