哪些参数请问stringlength属性errormessage的需要? [英] What parameters does the stringlength attribute errormessage take?

查看:842
本文介绍了哪些参数请问stringlength属性errormessage的需要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MVC4模板中使用的数据注解的属性之一是stringlength

In the MVC4 template one of the data annotation attributes used is stringlength.

例如:

[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]

哪些参数{0},{1},{2}(更多?)是合法的?

What parameters {0}, {1}, {2} (more?) are legal?

编辑:更具体,我可以从这个例子,试看看和错误的可能性是什么,但我想看看一些硬文档

To be more specific, I can see from the example and trial and error what the possibilities are, but I would like to see some hard documentation.

我无法找到有关此方面的任何 StringLengthAttribute文档

I can't find anything about this in the StringLengthAttribute documentation.

推荐答案

{0} 指数的财产, {1显示名称} MaximumLength {2} MinimumLength 。所以,你的错误信息将作为甲酸foo的长度必须至少6个字符。

The {0} index is the display name of property, {1} is the MaximumLength, {2} is the MinimumLength. So, your error message will be formate as "The Foo must be at least 6 characters long."

这篇关于哪些参数请问stringlength属性errormessage的需要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆