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

Joe Mackey
Joe Mackey
18,708 Points

Challenge 3 of 3

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

<h2>@ViewBag.Title</h2>

@using (Html.BeginForm())
{

    <div>
        @Html.TextBox("Name")
        <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="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>


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

}

2 Answers

Joe Mackey
Joe Mackey
18,708 Points

The challenge ask that I use Html.TextBox method. What am I doing wrong here?

Jon Wood
Jon Wood
9,857 Points

The @Html.TextBox("Name") is correct, but the challenge is probably failing because I think that's where the label is. I think it should be:

@Html.Label("Name")
@Html.TextBox("Name")