0

I am using the code from the below link. It works fine . But though there are validation errors, and ValidationSummary(true/false) is enabled, I am not able to see the validation message.

ASP.NET MVC Partial view ajax post?

As a work around ,When I try to display error message explicitly using the below code, it still does not display .When in debug mode, the ModelState has the error message , but it does not display .

 <div>
 @{
    foreach (var i in ViewData.ModelState.Values)
    {

        <ol>
            @{
                if(i.Errors != null && i.Errors.Count>0)
               {
                   var error = i.Errors[0];
                  <li>error.ErrorMessage</li> 
                }
              }
         </ol> 
       }
   }
</div>

Please help.

1 Answer 1

1

You can use @Html.ValidationMessage html helper to display property-level validation message in your partial view.

Sign up to request clarification or add additional context in comments.

1 Comment

I am using this code on the properties @Html.ValidationMessageFor(Model => Model.UserName)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.