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

Stuck on this challenge.

In this other challenge: task 2/3: "In Report.cshtml update the Html.Label method call for the "Name" field to its strongly typed version Html.LabelFor."

[8:10] I tried to copy what he did in the video but I get an error "Did you replace the 'Name' field's Html.Label method call with its strongly typed version Html.LabelFor?"

I added For to @HTML.Label and replaced "Name" with (m => m.Name)

Report.cshtml
@model IssueReporter.Models.Issue

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

<h2>@ViewBag.Title</h2>

@using (Html.BeginForm())
{
    <div>
        @Html.LabelFor (m => m.Name)
        @Html.TextBox("Name")
    </div>

    <div>
        @Html.Label("Email")
        @Html.TextBox("Email")
    </div>

    <div>
        @Html.Label("DepartmentId")
        @Html.TextBox("DepartmentId")
    </div>

    <div>
        @Html.Label("Severity")
        @Html.TextBox("Severity")
    </div>

    <div>
        @Html.Label("Reproducible")
        @Html.TextBox("Reproducible")
    </div>

    <div>
        @Html.Label("DescriptionOfProblem")
        @Html.TextArea("DescriptionOfProblem")
    </div>

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

2 Answers

Kevin Gates
Kevin Gates
14,796 Points

It accepts this:

 @Html.LabelFor(m=>m.Name)
Steven Parker
Steven Parker
203,731 Points

It shouldn't make a difference in real code, but the challenge apparently doesn't like the space between the method name and the parenthesis.

You may want to report this as a bug to Support.