Asp.Net MVC - 更改错误类的名称 [英] Asp.Net MVC - Change error class name

查看:161
本文介绍了Asp.Net MVC - 更改错误类的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Asp.Net MVC做实地验证,它会生成以下错误CSS类:

When I do field validation in Asp.Net MVC, it's generated the following error css classes :


  • 输入验证错误

  • 字段验证错误

有没有办法,我可以改变所生成的错误类的名称的方式?

Is there a way that I can change the names of the error classes that are generated?

我用XVAL。

推荐答案

我不知道XVAL但至于事情的ASP.NET MVC一边走,如果你看一下的来源你会看到有一些重新present这些价值观的一些静态只读字符串

I don't know about xVal but as far as the ASP.NET MVC side of things go, if you have a look at the source you'll see there are some static readonly strings that represent these values.

public static readonly string ValidationInputCssClassName = "input-validation-error";
public static readonly string ValidationMessageCssClassName = "field-validation-error";
public static readonly string ValidationSummaryCssClassName = "validation-summary-errors";

因此​​,无论你编辑源根据自己的喜好(也可能修复XVAL)或改变输出code以某种方式使用不同的值。

So either you edit the source to your liking (which may also fix xVal) or alter the outputting code to use different values somehow.

如果XVAL使用jQuery验证(我认为它...?)你可以改变它的'errorClass'选项默认值。 <一href=\"http://stackoverflow.com/questions/1724790/asp-net-mvc-validationsummary-for-client-side-validation/1726913#1726913\">My回答这里可以帮助你沿着这条道路。

If xVal is using jQuery Validation (which I think it does...?) you could change it's default value for the 'errorClass' option. My answer here could help you along that path.

HTHS,结果
查尔斯

HTHs,
Charles

这篇关于Asp.Net MVC - 更改错误类的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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