This is my model:
namespace MvcApplication2.Models
{
public class CreditCard
{
[CreditCard(ErrorMessageResourceType = typeof(Messages), ErrorMessageResourceName = "CardNumberInvalid")]
public string CardNumber { get; set; }
}
}
This is my Messages.resx:
Name Value
CardNumberInvalid Check your card number is correct
And this is my view:
@model MvcApplication2.Models.CreditCard
@Html.TextBoxFor(m => m.CardNumber);
In MVC version 3 this works without error. In MVC 4 when I go to this page I get an excpetion saying "Either ErrorMessageString or ErrorMessageResourceName must be set, but not both". This is only happening with the CreditCardAttribute. Other validation attributes such as RequiredAttribute work fine. I have only set the ErrorMessageResourceName. I have not set the ErrorMessageString, so do not understand what I have done wrong. Can anyone help please?