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 trial

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
229,744 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