Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You don't say what the errors are that are not displaying, but there are some errors which will be displayed in ValidationMessage but not in ValidationSummary. I think that this is a bug in the Release Candidate, but I am open to other interpretations. In particular, consider this line from the ValidationSummary source code:</p> <pre><code>string errorText = GetUserErrorMessageOrDefault(modelError, null /* modelState */); </code></pre> <p>Note that nothing is passed for modelState. Now contrast that with ValidationMessage:</p> <pre><code>... GetUserErrorMessageOrDefault(modelError, modelState) ... </code></pre> <p>Finally, let's look at GetUserErrorMessageOrDefault:</p> <pre><code> private static string GetUserErrorMessageOrDefault(ModelError error, ModelState modelState) { if (!String.IsNullOrEmpty(error.ErrorMessage)) { return error.ErrorMessage; } if (modelState == null) { return null; } string attemptedValue = (modelState.Value != null) ? modelState.Value.AttemptedValue : null; return String.Format(CultureInfo.CurrentCulture, MvcResources.Common_ValueNotValidForProperty, attemptedValue); } </code></pre> <p>What this tells us is that if you specify a custom error message when you add an error to the model state, it will be displayed. If, however, an exception is added (there is one overload for AddModelError which takes an exception, another which takes a string; implementing IDataErrorInfo works like the string case), instead of a string error message, it will only be displayed if modelState is non-null, and then we'll give you a generic message instead of the error message on the exception.</p> <p><strong>Update</strong></p> <blockquote> <p>Does ValidationSummary use ErrorMessage and ValidationMessage use InnerException.Message?</p> </blockquote> <p>Yes, that's more or less the effect. Like I said, I think this is a bug.</p> <p><strong><em>Update2</em></strong></p> <p>Microsoft updated the GetUserErrorMessageOrDefault function as seen <a href="http://aspnetwebstack.codeplex.com/SourceControl/changeset/view/f1511797ea32#src%2fSystem.Web.Mvc%2fHtml%2fValidationExtensions.cs" rel="nofollow noreferrer">here</a>.</p> <pre><code>private static string GetUserErrorMessageOrDefault(HttpContextBase httpContext, ModelError error, ModelState modelState) { if (!String.IsNullOrEmpty(error.ErrorMessage)) { return error.ErrorMessage; } if (modelState == null) { return null; } string attemptedValue = (modelState.Value != null) ? modelState.Value.AttemptedValue : null; return String.Format(CultureInfo.CurrentCulture, GetInvalidPropertyValueResource(httpContext), attemptedValue); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload