【发布时间】:2017-12-01 14:34:35
【问题描述】:
我正在尝试将两个密码字段与比较属性进行比较,在我的项目中,我使用 HTML 帮助程序根据语言 ID 获取不同语言的消息,但我无法在错误消息中使用我的方法
[LocalizedRequired("PasswordRequired")]
public string Password { get; set; }
[LocalizedRequired("PasswordDoesntMatch")]
[System.ComponentModel.DataAnnotations.CompareAttribute("Password", ErrorMessage = "Password doesn't match.")]
public string ConfirmPassowrd { get; set; }
这是没有助手的模型,它工作正常,问题是如果我使用任何返回字符串错误消息的方法,它根本不起作用。
[LocalizedRequired("PasswordRequired")]
public string Password { get; set; }
[LocalizedRequired("PasswordDoesntMatch")]
[System.ComponentModel.DataAnnotations.CompareAttribute("Password", ErrorMessage = Kuvendi.Infrastructure.MVC.HtmlHelperExtensions.DrawLabel("Password doesn't match")))]
public string ConfirmPassowrd { get; set; }
Draw label是一个HTML helper方法,它返回特定语言id的字符串,helper成功返回字符串并经过测试。
感谢您的宝贵时间。
【问题讨论】:
-
“根本不起作用”:请在问题中显示您的非工作代码并解释它与您的不同之处期待。
-
好的,我现在就编辑它
标签: c# .net asp.net-mvc