title: MVC TextBox with name specified not binding model on post
body: <p>This is like MVC 101 here so I feel completely helpless on why this isn't working. I have an extremely basic Model:</p>
  
  <pre><code>public class StockEnrollmentModel
  {
      [Required]
      [DisplayName("Employee Name:")]
      public string EmployeeName { get; set; }
  
  }
  </code></pre>
  
  <p>My view looks like this:</p>
  
  <pre><code>@using (Html.BeginForm("SimulateForm", "HR", FormMethod.Post))
  {
  &lt;div class="row"&gt;
      &lt;div class="col-md-6"&gt;
          &lt;div class="form-group"&gt;
              @Html.LabelFor(e =&gt; e.EmployeeName)
              @Html.TextBox("stock_employee_name", Model.EmployeeName)
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;button type="submit" class="btn btn-primary" value="Submit"&gt;Submit&lt;/button&gt;
  }
  </code></pre>
  
  <p><strong>The web service I will be posting to requires specific names for the input fields in order to successfully receive the data</strong></p>
  
  <p><strong>As in, the rendered html needs to read:</strong> </p>
  
  <pre><code>&lt;input type="stock_employee_name" type="text" /&gt; 
  </code></pre>
  
  <p>After much googling, I determined I need to use an Html.Text box in order to have control of the name attribute that is generated.</p>
  
  <p>The problem I'm having is that when I submit the form, the model in my controller is completely void of data. Investigating this shows that the form posted to the server with "employee_stock_name=Some Name" rather than "EmployeeName=Some Name"</p>
  
  <p>From my research, this shouldnt be happening, correct?? This exact situation should be the reason you use TextBox instead of TextBoxFor.</p>
  
  <p>What am I missing?</p>
  
  <p>Here is my controller for what its worth:</p>
  
  <pre><code>[HttpPost]
      public RedirectToRouteResult SimulateForm(StockEnrollmentModel model )
      {
          if ( ModelState.IsValid )
          {
              return RedirectToAction("SignForm", "HR", model);
          }
          return RedirectToAction("StockPurchase", model );
      }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The accepted answer below was what I eventually ended up using. There's no real way to easily change the name of the HTML field and maintain the MVC model binding. I ended up changing my property names to match what I needed the name field to read.</p>