Either ErrorMessageString or ErrorMessageResourceName must be set, but not both error using CreditCardAttribute

前端 未结 8 1904
囚心锁ツ
囚心锁ツ 2020-12-24 04:44

This is my model:

namespace MvcApplication2.Models
{
    public class CreditCard
    {
        [CreditCard(ErrorMessageResourceType = typeof(Messages), Error         


        
相关标签:
8条回答
  • 2020-12-24 05:42

    It's a known issue in .Net 4.5. Adding "ErrorMessage = null" named parameter should solve this.

    Reference: Reference link is broken now. http://connect.microsoft.com/VisualStudio/feedback/details/757298/emailaddress-attribute-is-unable-to-load-error-message-from-resource-mvc

    0 讨论(0)
  • 2020-12-24 05:48
    [CreditCard(ErrorMessageResourceType = typeof(Messages), ErrorMessageResourceName = "CardNumberInvalid", ErrorMessage = null)]
    

    Adding the ErrorMessage = null will fix your problem.

    0 讨论(0)
提交回复
热议问题