title: Confirmation password issue in MVC3
body: <p>I use the following model to control user input and to register him.
  But if I input the same passwords and press a button <strong>the message about that confirmation password is wrong appears.</strong></p>
  
  <p>I am sure about the model is correct because it works in some other page.
  In this case <strong>RegisterModelSecond</strong> is a member of <strong>EventFrontEndViewModel</strong>.  </p>
  
  <p>So when I comment <code>[Compare("RegisterModel.Password", ErrorMessage = "The password and confirmation password do not match.")]</code> it works but no confirmation I need!</p>
  
  <p>Any clue how to fix it?</p>
  
  <pre><code>public class EventFrontEndViewModel
      {
          public Page CurrentPage { set; get; }
  
          public List&lt;Event&gt; Events { set; get; }
  
          public List&lt;Event&gt; SubscribedEvents { set; get; }
  
          public RegisterModelSecond RegisterModel { set; get; }
  
          public EventFrontEndViewModel()
          {
              CurrentPage = new Page();
              Events = new List&lt;Event&gt;();
              RegisterModel = new RegisterModelSecond();
              SubscribedEvents = new List&lt;Event&gt;();
          }
      }
  </code></pre>
  
  <p>Register Model</p>
  
  <pre><code>public class RegisterModelSecond
      {
          [Required]
          [Display(Name = "User name")]
          public string UserName { 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; }
  
          [Required]
          [DataType(DataType.Password)]
          [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
          [Display(Name = "Confirm password")]
          [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
          public string ConfirmPassword { get; set; }
      }
  </code></pre>
  
  <p>and HTML </p>
  
  <pre><code>&lt;div class="editor-label"&gt;
                                          @Html.LabelFor(m =&gt; m.RegisterModel.Password)
                                      &lt;/div&gt;
                                      &lt;div class="editor-field"&gt;
                                          @Html.PasswordFor(m =&gt; m.RegisterModel.Password)
                                          @Html.ValidationMessageFor(m =&gt; m.RegisterModel.Password)
                                      &lt;/div&gt;
                                      &lt;div class="clear"&gt;
                                      &lt;/div&gt;
                                      &lt;div class="editor-label"&gt;
                                          @Html.LabelFor(m =&gt; m.RegisterModel.ConfirmPassword)
                                      &lt;/div&gt;
                                      &lt;div class="editor-field"&gt;
                                          @Html.PasswordFor(m =&gt; m.RegisterModel.ConfirmPassword)
                                          @Html.ValidationMessageFor(m =&gt; m.RegisterModel.ConfirmPassword)
                                      &lt;/div&gt;
                                      &lt;div class="clear"&gt;
                                      &lt;/div&gt;
  </code></pre>