C# ASP.NET MVC Forms Creating a Basic Form Using HTML Helpers

Roger Sullivan
Roger Sullivan
8,498 Points

move the form into a using statement with Begin.Html()

so my understanding here is that i need to wrap the existing form in a @using (Html.BeginForm()){ } statement. i started leaving out the H2 tag with the viewbag title. but it asked if i had moved all the markup so i then added that, with no html left to move im a bit perplexed by it still asking if i moved all the markup.

Report.cshtml
@{
    ViewBag.Title = "Report an Issue";
}

@using(Html.BeginForm())
{
  <h2>@ViewBag.Title</h2>

 <form method="post">

      <div>
          <label for="Name">Name</label>
          <input type="text" id="Name" name="Name" />
      </div>

      <div>
          <label for="Email">Email</label>
          <input type="text" id="Email" name="Email" />
      </div>

      <div>
          <label for="DepartmentId">Department</label>
          <input type="text" id="DepartmentId" name="DepartmentId" />
      </div>

      <div>
          <label for="Severity">Severity</label>
          <input type="text" id="Severity" name="Severity" />
      </div>

      <div>
          <label for="Reproducible">Reproducible</label>
          <input type="text" id="Reproducible" name="Reproducible" />
      </div>

      <div>
          <label for="DescriptionOfProblem">Description of Problem</label>
          <textarea id="DescriptionOfProblem" name="DescriptionOfProblem"></textarea>
      </div>

      <button type="submit">Save</button>

  </form>
}
Roger Sullivan
Roger Sullivan
8,498 Points

error reads "Bummer: Did you move the remaining form markup into your using statement?"

1 Answer

Steven Parker
Steven Parker
204,003 Points

Your "using" statement should replace the <form> tag on the line below the heading.

Also, the closing brace of the block should replace the ending </form> tag.