变更信息默认@ Html.ValidationMessageFor MVC 4 [英] Change message default @Html.ValidationMessageFor mvc 4

查看:825
本文介绍了变更信息默认@ Html.ValidationMessageFor MVC 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图改变从 @ Html.ValidationMessageFor 消息默认。哪里是谁,我可以恰克消息的文件:的_nameFied字段是必需的

I try to change the message default from @Html.ValidationMessageFor. Where is the file who i can chage the message: The _nameFied field is required.

查看:

@ Html.ValidationMessageFor(型号=> model.NumDoc,新{@class =错误输入})

推荐答案

您可以用它做在你的模式类的特定属性的<一个href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.requiredattribute%28v=vs.110%29.aspx\"相对=nofollow>在要求属性。

You can do it in your modal class's specific property using the ErrorMessage property in the of Required attribute.

例如:

public class MyClass{

    [Required(ErrorMessage = "My validation error message goes here")] //give your validation message here
    [Display(Name = "My display name")] //Give your display name here
    public int NumDoc{ get; set; }
}

这篇关于变更信息默认@ Html.ValidationMessageFor MVC 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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