class MyMaxLength : MaxLengthAttribute
{
public static String MyErrorMessage = "Maksimalna dolžina za polje {0} je {1}";
public MyMaxLength(int length)
{
new MaxLengthAttribute(length);
}
public override string FormatErrorMessage(string name)
{
if (!String.IsNullOrEmpty(ErrorMessage))
{
ErrorMessage = MyErrorMessage;
}
return String.Format(CultureInfo.CurrentUICulture, ErrorMessageString, name);
}
}
but I am having a problem with MyMaxLength(int length) constructor. The super class is never called. How can i create my own length validation with predefined message.