You are designing an ASP.NET MVC 2 Web application.
The Web application must meet the following requirements:
– Validate all user input for a class named Customer.
– Perform client-side and server-side validation.
You need to recommend an approach for validating user input.
What should you recommend?
A.
Use ASP.NET validation server controls. Call the Html.EnableClientValidation() method.
B.
Use only strongly typed HTML helpers.
Call the Html.ValidationMessageFor() method for each property in the Customer class.
C.
Add DataAnnotations attributes to each property in the Customer class.
Associate all rendered elements with a validation group.
D.
Add DataAnnotations attributes to each property in the Customer class.
Call the Html.EnableClientValidation() method.
Explanation:
Within the view (or a master page), reference the required scripts and call the Html.EnableClientValidation HTML helper
MVC 3 changes client validation in several ways. First, it leverages jQuery, jQuery.Validate, and jQuery.Validate.Unobtrusive-Ajax instead of ASP.NET AJAX. Second, you no longer need to manually call Html.EnableClientValidation, because it is enabled by default