ASP.NET MVC client validation from Service Layer -


I am following this article

Including a service layer To business logic in my ASP.NET MVC web application

I am able to pass messages from service level in Html.ValidationSummary using ModelState class.

I do the basic model validation (using the DataAnnotation attribute) based on the original model and I have enabled ClientValidation by default, which Displaying an error message on every single field in my form .

Professional logic error messages that come from the service layer are displayed on the HTML. Validate only after posting a form on the server.

After verification from the service level, I would like to highlight one or more fields and get the message from the service layer displayed on this field, which is the Html.ValidationSummary .

Any idea how to do this?

How verification looks here: server

  protected child valid Product (product product transferability) {if (string.IsNullOrEmpty (productToValidate.Name)) _validatonDictionary.AddError ("name", "name is required."); If (string.IsNullOrEmpty (productToValidate.Description)) _validatonDictionary.AddError ("Details", "Description Required."); If (Product Provinitive Units Instock & lt; 0) _validatonDictionary.AddError ("Units Install", "Units in the stock can not be less than zero."); Return _validatonDictionary.isvalid; }   

To see what you have to do, refer to the related validationmessageFor assistants for those areas and related error messages from the server related fields:

  @using (HTML.BeginForm ()) {& lt; Div & gt; @HTMLLLFLF (X = & gt; x.Name) @HTML. Editor (x = & gt; x .nom) @html Validation permeates (x = & gt; x.num) & lt; / Div & gt; & Lt; Div & gt; @HTMLLabelFor (X => X.Description) @HTMLEditorFor (X = & gt; X.Description) @HTML. Validation message (x = & gt; x description) & lt; / Div & gt; & Lt; Button type = "submit" & gt; Create & lt; / Button & gt; }    

Comments