2
I want to do a validation with the size of a field of the type int
using Dataannotation, I used [MaxLengthAttribute(10)]
, only at the moment that I will make the View
Index to bring up the list of entries, returns an error.
This is my code:
[Display(Name = "RE")]
[Required(ErrorMessage = "informe o RE")]
[MaxLengthAttribute(10)]
public int usuRE { get; set; }
This is the mistake:
"There was an error running the select code Retrieve Metadata for 'Loginuser.Models.Usuario'. The Property 'usere' is not a String or Byte array. Length can only be configured for String and Byte array properties.'"
Is there any other way I can validate the size of this field using Dataannotation?
A colleague said I could take the [MaxLengthAttribute(10)]
to HTML and do that validation there, but I don’t know how to do that, someone could help me?
Hello @Rafael. Put your structured code on your question instead of posting images. The same for the error message.
– João Martins
Okay, you can leave it, next time I’ll do it, sorry!
– Rafael
You can do it now! Edit your question and enter the code :)
– João Martins