Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC 2 EditorForModel() is rendering type=text instead of type=password
    primarykey
    data
    text
    <p>I have a Registration form that is populated using a ViewModel and Html.EditorForModel(). Among other fields in the model there are a Password and ConfirmPassword field. Both are marked with the DataType(DataType.Password) attribute. Locally, it renders properly, but on my server the Password field renders as a text field but the ConfirmPassword renders as a password field. Any thoughts as to why? I've checked and the server does not have extra templates that could cause it to render differently.</p> <p>Model:</p> <pre><code>public class RegisterModel : ValidatableModel { [Required] [DisplayName("First Name")] public string FirstName { get; set; } [Required] [DisplayName("Last Name")] public string LastName { get; set; } [Required] [EmailAddress(ErrorMessage = "The email address is not formatted correctly")] [DisplayName("Email address")] public string Email { get; set; } [Required] public string Title { get; set; } [Required] public string Organization { get; set; } [Required] [DisplayName("Address 1")] public string Address1 { get; set; } [DisplayName("Address 2")] public string Address2 { get; set; } [Required] public string City { get; set; } [Required] [UIHint("States")] public string State { get; set; } [Required] [ZipCode] public string Zip { get; set; } [Required] [DisplayName("Phone Number")] [PhoneNumber(ErrorMessage = "The phone number is not formatted correctly")] public string Phone { get; set; } [Required] [DisplayName("Area Account")] [UIHint("AreaAccountId")] public int AreaAccountId { get; set; } [Required] [ValidatePasswordLength] [DataType(DataType.Password)] [DisplayName("Password")] public string Password { get; set; } [DataType(DataType.Password)] [DisplayName("Confirm password")] public string ConfirmPassword { get; set; } [Required] [DisplayName("Password Hint")] public string PasswordHint { get; set; } public override IEnumerable&lt;ValidationResult&gt; Validate(ValidationContext validationContext) { if (Password != ConfirmPassword) yield return new ValidationResult("The password and confirmation password do not match.", new string[] { "Password", "ConfirmPassword" }); } } </code></pre> <p>Markup:</p> <pre><code>&lt;% using (Html.BeginForm()) { %&gt; &lt;%: Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.") %&gt; &lt;div&gt; &lt;fieldset&gt; &lt;legend&gt;Account Information&lt;/legend&gt; &lt;%: Html.EditorForModel() %&gt; &lt;p&gt; &lt;input type="submit" value="Register" /&gt; &lt;/p&gt; &lt;/fieldset&gt; &lt;/div&gt; &lt;% } %&gt; </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.
    1. This table or related slice is empty.
    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