Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC3 Validation Type Names Error
    primarykey
    data
    text
    <p>I get the following error:</p> <pre><code> Validation type names in unobtrusive client validation rules must be unique. The following validation type was seen more than once: required </code></pre> <p>I have no idea why, I have read some stuff about custom validation and ninject, but I don't think it is that.</p> <p>I am creating a custom account management system where administrators can create/edit users. I'm using the <code>ASP.NET Membership, Role, Profile</code>. When you create a new application with <code>Internet</code> ticked it creates all that account stuff. All I tried to do was reuse the <code>RegisterModel</code> that is provided with that in my <code>AccountManagement</code> <code>Area</code>. But then the error started to appear, I don't have any custom validation providers or anything. The error/exception also appears in <code>Account</code> <code>Views</code> as well (the ones created by the MVC template).</p> <p>The error happens on this line of the view:</p> <pre><code>&lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.User.UserName) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.TextBoxFor(model =&gt; model.User.UserName) &lt;!-- THIS LINE --&gt; @Html.ValidationMessageFor(model =&gt; model.User.UserName) &lt;/div&gt; </code></pre> <p>My Model is a <code>ViewModel</code> class with a property:</p> <pre><code>public RegisterModel User {get;set;} </code></pre> <p>I have wrote this entire website with no problems in the way I do anything apart from when it came to just reusing <code>RegisterModel</code>. Since then I have tried creating a completely new <code>Model</code> called <code>NewUserModel</code> and referencing that solely in the <code>Area</code> to no avail.</p> <p>I use the <code>DependencyResolver</code> to use <code>Ninject</code> as my IoC/DI. I can't imagine that to be a problem....</p> <p>Model:</p> <pre><code>namespace MyApplication.Areas.AccountManagement.Models { using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; public class NewUserModel { [Required] [Display(Name = "User name")] public string UserName { get; set; } [Required] [Display(Name = "First Name")] public string FirstName { get; set; } [Required] [Display(Name = "Last Name")] public string LastName { get; set; } [Required, RegularExpression(@"[0-9]{8}", ErrorMessage = "Please enter in an 8 digit Intel Worldwide Id")] [Display(Name = "WWID")] public string WWID { get; set; } [Required] [DataType(DataType.EmailAddress)] [Display(Name = "Email address")] public string Email { get; set; } [Required] [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] [DataType(DataType.Password)] [Display(Name = "Password")] public string Password { get; set; } [DataType(DataType.Password)] [Display(Name = "Confirm password")] [System.Web.Mvc.Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] public string ConfirmPassword { get; set; } } } </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.
 

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