将模型属性添加到错误消息 [英] Add Model Property to Error Message
本文介绍了将模型属性添加到错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个Model Employee,其中有两个属性Id和EmpName。在EmpName中已经应用了必需的验证器,我需要显示的消息是
请输入员工姓名{0}。
和{0}的值应来自Model Id字段。
任何人都可以建议怎么可能。
感谢高级
解决方案
你应该使用Custom验证。
请查看此链接 http://www.dotnetcurry。 com / ShowArticle.aspx?ID = 776 [ Custom验证]
Hi Everybody,
I have a Model Employee in which have two properties Id and EmpName. In EmpName have apply Required Validator and the Message i need to Display is
"Please enter the Employee name of {0}".
and the value of {0} should comes from the Model Id Field.
Can anyone please suggest how can it possible.
Thanks in advanced
解决方案
Hi,
U should be using Custom Validation for that.
Take a look at this link http://www.dotnetcurry.com/ShowArticle.aspx?ID=776[Custom Validation]
这篇关于将模型属性添加到错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文