Рет қаралды 78,724
Link for code samples used in the demo
csharp-video-tu...
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our KZbin channel. Hope you can help.
/ @aarvikitchen5572
Link for csharp, asp.net, ado.net, dotnet basics, mvc and sql server video tutorial playlists
www.youtube.co...
In this video, we will discuss displaying all validation errors at one place using validation summary html helper. A red asterisk (start) should be displayed next to every field that has failed the validation. The output should be as shown below.
We will be working with the example that we discussed in Part 85. Please watch Part 85, before proceeding.
First of all, the validation error messages should be displayed in red color. On the "Edit" view, include a reference to Site.css style sheet.
[link href="~/Content/Site.css" rel="stylesheet" type="text/css" /]
In site.css there are 3 css classes that control the display of validation error messages. Adjust the styles of these classes according to your needs.
field-validation-error
input.input-validation-error
validation-summary-errors
To display all errors at one place, use ValidationSummary() HTML helper.
@Html.ValidationSummary(false, "Please fix the following errors and then submit the form")
To display an asterisk, next to the field that has failed validation, modfiy ValidationMessageFor() html helper as shown below.
@Html.ValidationMessageFor(model =] model.Name, "*")
At this point, next to the field that has failed the validation message, a star symbol will be displayed instead of the detailed error message. All the detailed error messages will be displayed using validation summary.
Please make sure to replace [ with LESSTHAN and ] with GREATERTHAN symbol.