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 trialLee Puckett
12,539 PointsNot sure how to add two more calls to the Html.RadioButtonFor HTML helper method
Having trouble with this challenge. In the video he removes the textboxfor and replaces it with the new @Html.RadioButtonFor, so I did that eveywhere I saw textboxfor. Instead of intensity I used severity (major and critical)
@model IssueReporter.Models.Issue
@using IssueReporter.Models
@{
ViewBag.Title = "Report an Issue";
}
<h2>@ViewBag.Title</h2>
@using (Html.BeginForm())
{
<div>
@Html.LabelFor(m => m.Name)
@Html.RadioButtonFor (m=> m.Severity "Major")
@Html.RadioButtonFor (m=> m.Severity "Critical")
</div>
<div>
@Html.LabelFor(m => m.Email)
@Html.RadioButtonFor (m=> m.Severity "Major")
@Html.RadioButtonFor (m=> m.Severity "Critical")
</div>
<div>
@Html.LabelFor(m => m.DepartmentId)
@Html.DropDownListFor(m => m.DepartmentId, (SelectList)ViewBag.DepartmentsSelectListItems)
</div>
public enum SeverityLevel
{
Major,
Critical
}
<div>
@Html.LabelFor(m => m.Severity)
@Html.RadioButtonFor(m => m.Severity,
Issue.SeverityLevel.Minor) @Issue.SeverityLevel.Minor
</div>
<div>
@Html.LabelFor(m => m.Reproducible)
@Html.RadioButtonFor (m=> m.Severity "Major")
@Html.RadioButtonFor (m=> m.Severity "Critical")
</div>
<div>
@Html.LabelFor(m => m.DescriptionOfProblem)
@Html.RadioButtonFor (m=> m.Severity "Major")
@Html.RadioButtonFor (m=> m.Severity "Critical")
</div>
<button type="submit">Save</button>
}
2 Answers
Steven Parker
231,271 PointsIt's important to read the challenge instructions carefully. The instructions say to add only two more calls. And the word "more" gives you a clue that you will be adding them in the "Severity" section, where one radio button already is.
And you'll be adding new code, you won't remove or replace anything provided to start with.
Lee Puckett
12,539 PointsThanks Steven
Lee Puckett
12,539 PointsLee Puckett
12,539 PointsOriginal code
@model IssueReporter.Models.Issue @using IssueReporter.Models
@{ ViewBag.Title = "Report an Issue"; }
<h2>@ViewBag.Title</h2>
@using (Html.BeginForm()) { <div> @Html.LabelFor(m => m.Name) @Html.TextBoxFor(m => m.Name) </div>
}