Part 86 - ValidationSummary in asp.net mvc
来源:互联网 发布:centos phphub5 编辑:程序博客网 时间:2024/05/17 22:14
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.
- Part 86 - ValidationSummary in asp.net mvc
- Part 60 - ViewStart in asp.net mvc
- How to use ValidationSummary control in asp.net
- Part 2 - View engines in asp.net mvc
- Part 54 - T4 templates in asp.net mvc
- Part 81 - Range attribute in asp.net mvc
- Part 82 - Creating custom validation attribute in asp.net mvc
- Part 83 - RegularExpression attribute in asp.net mvc
- Part 84 - Compare attribute in asp.net mvc
- Part 85 - Enable client side validation in asp.net mvc
- Part 88 - Unobtrusive validation in asp.net mvc
- Part 89 - Remote validation in asp.net mvc
- ASP.NET表单验证之ValidationSummary控件
- ASP.NET MVC Framework (Part 1)
- 【转】ASP.NET MVC Framework (Part 1)
- 【转】ASP.NET MVC Framework (Part 1)
- Asp.Net MVC 视图(概述) - Part.1
- Asp.Net MVC 视图(概述) - Part.1
- QT/C++ 下调用python自定义模块
- dom级别
- Part 85 - Enable client side validation in asp.net mvc
- java泛型
- HDU 1215 七夕节(筛选法)
- Part 86 - ValidationSummary in asp.net mvc
- 欢迎使用CSDN-markdown编辑器
- cocoapods的坑你踩了么?
- Linux静态库与动态库
- 跨域访问
- Javascript小结(一)----prototype对象
- Android教程:Webview自适应屏幕
- javaWeb基础知识----Cookie,Session
- QTCreator2.8.0+Qt Open source 4.8.5环境配置(Win7x64)