
Steven Scott
7,542 PointsIn Report.cshtml update the Html.Label method call for the "Name" field to its strongly typed version Html.LabelFor.
Does anyone have a passing answer for challenge 2 and 3?
@model IssueReporter.Models.Issue
@{
ViewBag.Title = "Report an Issue";
}
<h2>@ViewBag.Title</h2>
@using (Html.BeginForm())
{
<div>
@Html.LabelFor (model => M)
@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>
}
1 Answer

Robert Stefanic
35,152 PointsYou're on the right track here.
@Html.LabelFor (model => M)
LabelFor takes an function here. So far, your function takes a model, and you want to access a property on that model. How would you normally access a property on an object?
That's what you'll add to the right of =>
. As a hint, M
isn't in scope here, so you need to change it to the variable name that you've defined to the left of =>
.