title: razor MVC foreach with @using (html.beginform())
body: <p>I need to create a form with a question and a text box to allow user enter their answer and send for validation. It seems <code>@using (Html.BeginForm())</code> is not valid with <code>@foreach</code>. Below is the code but I am not sure if this is the correct way. Can someone point me in the right direction please? Or how can I use <code>@using (Html.BeginForm())</code> for the scenario. </p>
  
  <pre><code>@model PairingTest.Web.Models.QuestionnaireViewModel
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;@Model.QuestionnaireTitle&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form action="~/Questionnaire/ProcessData" method="post"&gt;
  
          @foreach (var s in Model.QuestionsText) {
  
              &lt;text&gt; Question :&lt;/text&gt;@s &lt;br /&gt;
              @Html.Label("Ans");&lt;br /&gt;
              @Html.TextBox("Ans");&lt;br /&gt; 
  
          }
  
          &lt;button type="submit"&gt;Submit&lt;/button&gt;
      &lt;/form&gt; 
  &lt;/body&gt;
  </code></pre>
  
  <p></p>