If use default attribte, then validation work on server and browser
[StringLength(100, MinimumLength = 6, ErrorMessageResourceName = "StrLenMinMax", ErrorMessageResourceType = typeof(Resources.Resources))]
public string Password { get; set; }
But if use custom attribute validation work only on server (validation on the page is only through an error by VIEW)
I am not have runtime validation, only after submit
[StringLengthEx(100, MinimumLength = 6)]
public string Password { get; set; }
public class StringLengthExAttribute : StringLengthAttribute
{
private const string StringLengthMin = "StrLenMin";
private const string StringLengthMinMax = "StrLenMinMax";
public StringLengthExAttribute(int maxLength):base(maxLength)
{
ErrorMessageResourceType = typeof(Resources.Resources);
if (MinimumLength != 0)
{
MinimumLength = MinimumLength;
ErrorMessageResourceName = StringLengthMinMax;
}
else
{
ErrorMessageResourceName = StringLengthMin;
}
}
}