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

Roger Sullivan
Roger Sullivan
8,498 Points

Did you move the remaining form markup into your using statement? Yes, yes i did, please help

It’s asking if i moved the markup into the using statement, I’ve tried doing it this way, as in the previous video and including the h2 tag which leaves no markup to move.

Report.cshtml
@{
    ViewBag.Title = "Report an Issue";
}
<h2>@ViewBag.Title</h2>

@using(Html.BeginForm())
{
<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>
}

1 Answer

Vicky Lien
Vicky Lien
2,880 Points

Because you are using Html.BeginForm(), there is no need for the form tag. Try removing <form method="post"> and </form> and you should be good!

Roger Sullivan
Roger Sullivan
8,498 Points

Oh god, thank you, i stared at this for like two hours