MVC Client Validation from Service Layer

Posted by GibboK on Stack Overflow See other posts from Stack Overflow or by GibboK
Published on 2012-07-09T18:42:37Z Indexed on 2012/07/09 21:15 UTC
Read the original article Hit count: 276

Filed under:
|
|
|
|

I'm following this article

http://www.asp.net/mvc/tutorials/older-versions/models-(data)/validating-with-a-service-layer-cs

to include a Service Layer with Business Logic in my MVC Web Application.

I'm able to pass messages from the Service Layer to the View Model in a Html.ValidationSummary using ModelState Class.

I perform basic validation logic on the View Model (using DataAnnotation attributes) and I have ClientValidation enabled by default which displaying the error message on every single field of my form.

The Business logic error message which come from the Service Layer are being displayed on Html.ValidationSummary only after Posting the form to the Server.

After Validation from the Service Layer I would like highlight one or more fields and have the message from the Service Layer showing on these fields instead that the Html.ValidationSummary. Any idea how to do it?

Thanks

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about asp.net-mvc