Note that there are some explanatory texts on larger screens.

plurals
  1. POChange default "The {0} field is required" (ultimate solution?)
    primarykey
    data
    text
    <p>Good day!</p> <p>I've the following ViewModel class I use for login form:</p> <pre><code>using System.ComponentModel.DataAnnotations; ... public class UserLogin : IDataErrorInfo { [Required] [DisplayName("Login")] public string Login { get; set; } [Required] [DisplayName("Password")] public string Password { get; set; } [DisplayName("Remember Me")] public bool RememberMe { get; set; } #region IDataErrorInfo Members // This will be a Model-level error public string Error { get { if (!WebUser.CanLogin(Login, Password)) { return Resources.ValidationErrors.InvalidLoginPassword; } else { return String.Empty; } } } // All is handled by DataAnnotation attributes, just a stub for interface public string this[string columnName] { get { return string.Empty; } } #endregion } </code></pre> <p>And this in <code>Global.asax</code>:</p> <pre><code>DefaultModelBinder.ResourceClassKey = "BinderMessages"; ValidationExtensions.ResourceClassKey = "BinderMessages"; </code></pre> <p>The resource file <code>BinderMessages.resx</code> is placed inside App_GlobalResources it has two keys <code>InvalidPropertyValue</code> (which works) and <code>PropertyValueRequired</code> which doesn't and gives me default message.</p> <p>Question: Is it possible to modify this message, or it's tied to DataAnnotations? </p> <p>I've found many posts about this, but without solution. For now I just fallback to this:</p> <pre><code>[Required(ErrorMessageResourceType = typeof(Resources.ValidationErrors), ErrorMessageResourceName = "Required")] </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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