I have a model classes that has a description property with a data annotation attribute of StringLength and length is set to 100 characters. When this property is more than 100
Why all the hassle? Why not
private string _description = string.Empty; [StringLength(100, ErrorMessage = "Description Max Length is 100")] public string Description { get { return _description; } set { _description = value.Substring(0,100); }; // or something equivalent }