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

trina joy
trina joy
6,525 Points

Helper Method MVC Forms...

i get the following error .. Did you replace the 'Name' label with a call to the Html.Label method?

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

<h2>@ViewBag.Title</h2>

@using (Html.BeginForm())
{

    <div>
        @Html.Label("Name", new ( @class = "control-label"})


    </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>

}

1 Answer

Steven Parker
Steven Parker
204,019 Points

:point_right: The challenge pointed out that "The label isn’t using any CSS classes".

It also said "you can use the first method overload that accepts a single string parameter". But you used the form that takes two parameters, and you set a class that wasn't there before!

Also, you accidentally deleted the input line that follows the label.