title: Javascript function updating the wrong field
body: <p>I'm using a javascript function to concatenate two fields FirstName and LastName into one single field FullNameText. </p>
  
  <p>This is the javascript function: </p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
  
          function loadFullName()
          {
  
              var lblFullNametext = document.getElementById('MainContent_frmAuthor_lblFullNameText');
              var txtAuthor_FirstName =   document.getElementById('&lt;% = frmAuthor.FindControl("txtAuthor_FirstName").ClientID %&gt;');
              var txtAuthor_LastName = document.getElementById('&lt;% = frmAuthor.FindControl("txtAuthor_LastName").ClientID %&gt;');
              var comma = "";
              if (txtAuthor_FirstName.value != "" || txtAuthor_LastName.value != "")
              {
                  comma = ", ";
              }
              document.getElementById('MainContent_frmAuthor_lblFullNameText').textContent = txtAuthor_LastName.value + comma + txtAuthor_FirstName.value;
  
  
          }
  
  
      &lt;/script&gt;
  </code></pre>
  
  <p>And this is my aspx code within a FormView:</p>
  
  <pre><code>    &lt;InsertItemTemplate&gt;
                      &lt;table style="width: 100%"&gt;
                           &lt;tr&gt;
                              &lt;td&gt;ID&lt;/td&gt;
                              &lt;td &gt;
                                  &lt;asp:Label ID
  
  ="txtAuthor_ID" runat="Server" Text="(New)" Width="50%" /&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
  
                          &lt;/td&gt;
                          &lt;td&gt;
  
                          &lt;/td&gt;
  
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;
                              &lt;asp:Label runat="server" ID="lblFullName" Text="Full Name" &gt;Full Name&lt;/asp:Label&gt;
  
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;asp:Label runat="server" ID="lblFullNameText" &gt;&lt;/asp:Label&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
  
                          &lt;/td&gt;
                          &lt;td&gt;
  
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;First Name &lt;span style="color:red"&gt;*&lt;/span&gt;&lt;/td&gt;
                          &lt;td&gt;
                              &lt;asp:TextBox ID="txtAuthor_FirstName" runat="Server" onkeyup="loadFullName();"
                                  /&gt;
                          &lt;/td&gt;
                           &lt;td&gt;Last Name&lt;/td&gt;
                          &lt;td&gt;
                              &lt;asp:TextBox ID="txtAuthor_LastName" runat="Server" onkeyup="loadFullName();"
                                  /&gt;
                          &lt;/td&gt;
  
                      &lt;/tr&gt;
  
                  &lt;/table&gt;
              &lt;/InsertItemTemplate&gt;
  </code></pre>
  
  <p>When I click a button Save in my FormView with both FirstName and LastName blank, the lblFullName field get replace by a comma, while the lblFullNameText remains blank.</p>
  
  <p>I'm certainly missing something here but I can't get my head around it. </p>
  
  <p>1) Why is the LoadFullName() being triggered while I haven't pressed any keys on the FirstName and LastName textboxes? There are also no references to that function in my code.</p>
  
  <p>2) Why is the lblFullName label being replace with a "comma" although the label that is supposed to change is lblFullNameText ?</p>
  
  <p>I would appreciate if someone can point me to the mistake I'm doing. Please let me know if I should provide any more information.</p>