MVC study - data validation
-
Data validation
Sever side:
- Required – Indicates that the property is a required field
- DisplayName – Defines the text we want used on form fields and validation messages
- StringLength – Defines a maximum length for a string field
- Range – Gives a maximum and minimum value for a numeric field
- Bind – Lists fields to exclude or include when binding parameter or form values to model properties
- ScaffoldColumn – Allows hiding fields from editor forms
Client side:
<%@ Import Namespace="MvcMusicStore"%>
<
script
src
=
"/Scripts/MicrosoftAjax.js"
type
=
"text/javascript"
></
script
>
<
script
src
=
"/Scripts/MicrosoftMvcAjax.js"
type
=
"text/javascript"
></
script
>
<
script
src
=
"/Scripts/MicrosoftMvcValidation.js"
type
=
"text/javascript"
></
script
>
<% Html.EnableClientValidation(); %>