@Html.ValidationSummary(true) - 真正的做法是什么? [英] @Html.ValidationSummary(true) - What's the true do?

查看:19
本文介绍了@Html.ValidationSummary(true) - 真正的做法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码包含:

@Html.ValidationSummary(true)

我查看了 MSDN 站点,但仍然看不到设置true"的作用是什么?我注意到的是,当我有针对字段的验证消息时,它仍然会创建一个空的验证摘要 DIV.

I looked at the MSDN site and still can't see what setting "true" does? What I notice is that when I have validation messages that are for fields then it still creates a validation summary DIV that's empty.

有没有办法抑制摘要 DIV 的创建,因为它们在例如我的字段重复时不显示任何内容.

Is there a way to supress the creating of the summary DIVs as they don't show anything when for example my field is a duplicate.

推荐答案

您可以针对属性或模型指定错误消息.使用validationsummary() 显示针对模型指定的那些.

You can specify error messages against the properties or against the model. Those specified against the model are displayed using the validationsummary().

bool 属性指示您是否希望在显示属性错误消息的同时显示验证摘要错误消息.如果您选择不这样做,则属性错误消息将首先显示给用户.然后,当用户解决了所有这些错误消息后,将在之后显示摘要错误消息.

The bool property indicates if you would like to display the validation summary error messages at the same time as displaying the property error messages. If you choose not to then the property error messages will be displayed to the user first. Then, when the user has resolved all of those error messages, the summary error messages will be displayed after.

如果 bool 参数为真,则仅显示模型级错误.如果参数为 false,则显示所有错误.

If the bool parameter is true then only model-level errors are displayed. If the parameter is false then all errors are shown.

这篇关于@Html.ValidationSummary(true) - 真正的做法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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