Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
540 views
in Technique[技术] by (71.8m points)

asp.net mvc - @Html.ValidationSummary(true) - What's the true do?

I have code that contains:

@Html.ValidationSummary(true)

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...