Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# ASP.NET MVC Forms Improving Our Form Radio Buttons

Not 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)

Report.cshtml
@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>
}

Original 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>

<div>
    @Html.LabelFor(m => m.Email)
    @Html.TextBoxFor(m => m.Email)
</div>

<div>
    @Html.LabelFor(m => m.DepartmentId)
    @Html.DropDownListFor(m => m.DepartmentId, (SelectList)ViewBag.DepartmentsSelectListItems)
</div>

<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.TextBoxFor(m => m.Reproducible)
</div>

<div>
    @Html.LabelFor(m => m.DescriptionOfProblem)
    @Html.TextAreaFor(m => m.DescriptionOfProblem)
</div>

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

}

2 Answers

Steven Parker
Steven Parker
218,734 Points

It'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.

Thanks Steven