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 I do the basic model validation (using the Professional logic error messages that come from the service layer are displayed on the 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 Any idea how to do this? How verification looks here: server To see what you have to do, refer to the related Html.ValidationSummary using
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 .
HTML. Validate only after posting a form on the server.
Html.ValidationSummary .
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; }
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
Post a Comment