Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSteven 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,170 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 =>
.