Friday, April 19, 2013

Override StringLength attribute in mvc DataAnnotation


public class MyStringLength : StringLengthAttribute
    {
        public MyStringLength(int maximumLength)
            : base(maximumLength)
        {
            base.ErrorMessage = Resource1.ResourceManager.GetString("MiniLength");//or use hard code message
            //base.ErrorMessageResourceName = Resource1.ResourceManager.GetString("MiniLength"); ;
            //base.ErrorMessageResourceType = typeof (Resource);
        }

    }

No comments:

Post a Comment