title: MVC Razor View: How to render a list of text boxes for a List<Task> in the model?
body: <p>I have a <code>List&lt;Task&gt;</code> in my model. This list contains 2 tasks(say) in it</p>
  
  <pre><code>public List&lt;Task&gt; Tasks { get; set; }
  
  public class Task    {
      public Task()
      {
          Title="";
          Total= 0;
      }
  
      public string Title{ get; set; }
  
      public int Total{ get; set; }
  }
  </code></pre>
  
  <p>Now in my razor view, I want render 2 text boxes for each of the <code>Tasks</code> in the <code>List&lt;Tasks&gt;</code> of my model.</p>
  
  <p>I didn't loop, just placed direct text boxes like:</p>
  
  <pre><code>@Html.TextBoxFor(m =&gt; m.Tasks[0].Title, new { @maxlength = "50"})
  @Html.TextBoxFor(m =&gt; m.Tasks[0].Total, new { @maxlength = "2"})
  &lt;br&gt;
  @Html.TextBoxFor(m =&gt; m.Tasks[1].Title, new { @maxlength = "50"})
  @Html.TextBoxFor(m =&gt; m.Tasks[1].Total, new { @maxlength = "2"})
  </code></pre>
  
  <p>This renders the form fine, but clicking the submit button doesn't do anything in FF.
  However it posts fine in IE9.</p>
  
  <p>View source shows this html generated like this:</p>
  
  <pre><code>&lt;input id="Tasks_0__Title" maxlength="50" name="Tasks[0].Title" type="text" value="" /&gt;
  &lt;input data-val="true" data-val-number="The field Total must be a number." data-val-required="The Total field is required." id="Tasks_0__Total" maxlength="2" name="Tasks[0].Total" type="text" value="" /&gt; 
  </code></pre>
  
  <p>This HTML doesn't look right. It has <code>name="Tasks[0].Total"</code> which seems odd.</p>
  
  <p>How should I do this so that I can access the text box values from <code>List&lt;&gt;</code> in my controller after post?</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT:</strong>
  I just kept one row for test. This is the html I see in FF.</p>
  
  <pre><code>&lt;input id="Tasks_0__Title" type="text" value="" name="Tasks[0].Title" maxlength="50"&gt;
  &lt;input id="Tasks_0__Total" type="text" value="" name="Tasks[0].Total" maxlength="2" data-val-required="The Total field is required." data-val-number="The field Total must be a number." data-val="true"&gt;
  </code></pre>
  
  <p>This doesn't post when I click the submit button.</p>
  
  <p>Now if I change <code>name="Tasks[0].Title" to name="Tasks_0__Title" and name="Tasks_0__Total"</code>
   in FIREBUG it posts fine.</p>
  
  <p>If I delete name completely it also posts fine in FF</p>