[英]Data Annotations will not be working for Textarea
I created an c# application with mvc4 in that I use one TextArea
for getting user input which must within the range of 15-100 I use data annotations for that But it will not working.Please anyone help me to solve this problem我用 mvc4 创建了一个 c# 应用程序,因为我使用一个
TextArea
来获取用户输入,它必须在 15-100 的范围内我为此使用数据注释但它不起作用。请任何人帮我解决这个问题
Here is my code这是我的代码
@Html.TextArea(model => model.Edit)
And this is my DataAnnotations
这是我的
DataAnnotations
[MinLength(15,ErrorMessage="Reason can't be less than 15 characters")]
[MaxLength(100,ErrorMessage="Reason can't be more than 100 characters")]
[Display(Name = "Edit" )]
public string Edit{ get; set; }
Instead use this而是使用这个
[StringLength(30, ErrorMessage = "Must be between {2} and {1} characters long.", MinimumLength = 15)]
Also, [Required]
is must另外,
[Required]
是必须的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.