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

Using HTML Helpers

Challenge Task 2 of 3

In Report.cshtml render the <label> element for the "Name" field using the Html.Label method. The label isn’t using any CSS classes, so you can use the first method overload that accepts a single string parameter for the expression to identify the property to display (MvcHtmlString HtmlHelper.Label(string expression)).

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

<h2>@ViewBag.Title</h2>

@using(Html.BeginForm())
{
    <div>
        @Html.Label("Name")
        <input type="text" id="Name" name="Name" />
    </div>

    <div>
        @Html.Label("Email")
        <input type="text" id="Email" name="Email" />
    </div>

    <div>
         @Html.Label("DepartmentId")
        <input type="text" id="DepartmentId" name="DepartmentId" />
    </div>

    <div>
         @Html.Label("Severity")
        <input type="text" id="Severity" name="Severity" />
    </div>

    <div>
         @Html.Label("Reproducible")
        <input type="text" id="Reproducible" name="Reproducible" />
    </div>

    <div>
        @Html.Label("DescriptionOfProblem")
        <textarea id="DescriptionOfProblem" name="DescriptionOfProblem"></textarea>
    </div>
}

1 Answer

Steven Parker
Steven Parker
204,019 Points

It looks like you did too much work.

The challenge said to "render the <label> element for the "Name" field using the Html.Label method". You did that, but then you also changed the rendering of all other labels on the page.

Just modify only the field mentioned in the challenge and you should move to the next task.

Just in general, always do ONLY what a challenge asks.