title: Updating the same property in two places on an MVC form
body: <p>I have two fields on an MVC3 form that must represent the same value.  If one is updated it should update the other and display the correct value (Gotta love requirements).  For what may be obvious reasons, the field (with the second one on the page) does not update properly.  Is there a way to achieve what I need?</p>
  
  <p>For example:</p>
  
  <p><strong>First Example</strong></p>
  
  <pre><code> &lt;li class="identifier-controls"            @Model.IdentifierConfigurator.GenerateDataAttributes("ssn")&gt;
          @Html.TextFieldFor("Social Security Number", m =&gt; m.SocialSecurityNumber).SSN()
      &lt;/li&gt;
  
  may appear twice on that form (In two different spots). (At this point, both of the controls have the same ID and name)
  </code></pre>
  
  <p>OR:</p>
  
  <p><strong>Second Example</strong></p>
  
  <pre><code>    &lt;li class="identifier-controls"            @Model.IdentifierConfigurator.GenerateDataAttributes("ssn")&gt;
         @Html.TextFieldFor("Social Security Number", m =&gt; m.SocialSecurityNumber).SSN()
      &lt;/li&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>    &lt;li class="identifier-controls"            @Model.IdentifierConfigurator.GenerateDataAttributes("ssn")&gt;
         @Html.TextFieldFor("Social Security Number", m =&gt; m.Person.Description.SSN).SSN()
      &lt;/li&gt;
  </code></pre>
  
  <p>will appear on the form.  At this point the IDs are different for the input but it will only update on of them.</p>
  
  <p>Here is the HTML that is generated:</p>
  
  <pre><code>&lt;ol class="field-list display"&gt;
  
    &lt;li id="party-name"&gt;&lt;span class="label"&gt;Name&lt;/span&gt;&lt;span id="FormalDisplayName" class="value" style="width:140px"&gt;Guy, Bad&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Aliases&lt;/span&gt;&lt;span id="AliasNames" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Status&lt;/span&gt;&lt;span id="PartyStatusName" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Gender&lt;/span&gt;&lt;span id="Description_Gender" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Juvenile&lt;/span&gt;&lt;span id="Description_IsJuvenile" class="value" style="width:140px"&gt;No&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Ethnicity&lt;/span&gt;&lt;span id="Description_Ethnicity" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Residential Status&lt;/span&gt;&lt;span id="Description_ResidentialStatus" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Marital Status&lt;/span&gt;&lt;span id="Description_MaritalStatus" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Religion&lt;/span&gt;&lt;span id="Description_Religion" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Citizenship&lt;/span&gt;&lt;span id="Description_Citizenship" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Birth City&lt;/span&gt;&lt;span id="Description_BirthCity" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Date of Birth&lt;/span&gt;&lt;span id="Description_BirthDate" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Date of Death&lt;/span&gt;&lt;span id="Description_DeathDate" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Est. Age at Incident&lt;/span&gt;&lt;span id="Description_EstimatedAgeAtIncident" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Adoption Date&lt;/span&gt;&lt;span id="Description_AdoptionDate" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Multiple Birth&lt;/span&gt;&lt;span id="Description_MultipleBirthName" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
    &lt;li&gt;&lt;span class="label"&gt;Email&lt;/span&gt;&lt;span id="Description_Email" class="notentered" style="width:140px"&gt;Not entered&lt;/span&gt;&lt;/li&gt;
  
  
  
      &lt;li&gt;&lt;span class="label"&gt;Identifiers&lt;/span&gt;&lt;span id="SuspectIdentifiersDisplay" class="value" style="width:400px"&gt;Prof&lt;span class='value-display'&gt;&amp;nbsp;123&lt;/span&gt;&lt;span class='separator'&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;FBI&lt;span class='value-display'&gt;&amp;nbsp;123&lt;/span&gt;&lt;span class='separator'&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;SSN&lt;span class='value-display'&gt;&amp;nbsp;222-22-2222&lt;/span&gt;&lt;span class='separator'&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;ITN&lt;span class='value-display'&gt;&amp;nbsp;123&lt;/span&gt;&lt;span class='separator'&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;BCI&lt;span class='value-display'&gt;&amp;nbsp;13&lt;/span&gt;&lt;span class='separator'&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;ID&lt;span class='value-display'&gt;&amp;nbsp;123&lt;/span&gt;&lt;span class='separator'&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;DL&lt;span class='value-display'&gt;&amp;nbsp;123&lt;/span&gt;&lt;span class='separator'&gt;&amp;nbsp;|&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
  
  &lt;/ol&gt;
  </code></pre>
  
  <p>The only difference between this HTML (this is the html from example two) and the HTML that is generated in the first example is that the two controls have the same ID and name.  Here is what happens in the controller method that is called by the BeginRouteForm html helper when submit is called:</p>
  
  <p>public ActionResult Update(int partyId, FormCollection data)
      {
        var party = Party.Find(partyId).OrNotFound();
        var vm = new PartyEditViewModel(party.Case, party);</p>
  
  <pre><code>  try
    {
      UpdateModel(vm, data);
  
      return JsView("Update.js", party);
    }
    catch (UpdateModelException)
    {
      return JsView("Edit.js", vm);
    }
  }
  </code></pre>