Q:

Derived RequiredAttribute doesn't work

I'm trying to implement my own RequiredAttribute, in which I call a custom resource handler:
public class LocalizedValidationAttributes
{
    public class LocalizedRequiredAttribute : RequiredAttribute
    {
        private String _resourceString = String.Empty;

        public new String ErrorMessage
        {
            get { return _resourceString; }
            set { _resourceString = GetMessageFromResource(value); }
        }
    }

    private static String GetMessageFromResource(String resourceTag)
    {
        return ResourceManager.Current.GetResourceString(resourceTag);
    }

}

I call this the following way:
[LocalizedValidationAttributes.LocalizedRequiredAttribute(ErrorMessage = "test")]
public String Text { get; set; }

But the getter of ErrorMessage is never called.
Any hints? Thanks!

A:

Try like this:
public class LocalizedRequiredAttribute : RequiredAttribute
{
    public override string FormatErrorMessage(string name)
    {
        return ResourceManager.Current.GetResourceString(name);
    }
}

or like this:
public class LocalizedRequiredAttribute : RequiredAttribute
{
    public LocalizedRequiredAttribute(string resourceTag)
    {
        ErrorMessage = GetMessageFromResource(resourceTag);
    }

    private static String GetMessageFromResource(String resourceTag)
    {
        return ResourceManager.Current.GetResourceString(resourceTag);
    }
}

and then:
[LocalizedValidationAttributes.LocalizedRequiredAttribute("test")]
public String Text { get; set; }

