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 Creating a Basic Form Using HTML Helpers

What's wrong with my Html.BeginForm() method?

May I know what I'm doing wrong with this practice? There were no classes given, so I've excluded those, but even with the addition of classes, the practice validation keeps throwing exception. The error I got was "Bummer, did you remove any of the provided code?" I'm not sure where to go from this.

Report.cshtml
@using (Html.BeginForm())
{
    <div>
        @Html.Label("Name")
        @Html.TextBox("Name", null)
    </div>

    <div>
      @Html.Label("Email")
        @Html.TextBox("Email", null)
    </div>

    <div>
      @Html.Label("DepartmentId")
        @Html.TextBox("DepartmentId", null)
    </div>

    <div>
      @Html.Label("Severity")
        @Html.TextBox("Severity", null)
    </div>

    <div>
      @Html.Label("Reproducible")
        @Html.TextBox("Reproducible", null)
    </div>

    <div>
      @Html.Label("DescriptionOfProblem")
        @Html.TextArea("DescriptionOfProblem", null, 14, 20)
    </div>

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

1 Answer

Steven Parker
Steven Parker
229,732 Points

Tasks 2 and 3 ask you to change the label and input elements to Html helper methods for the "Name" field, but it looks like you changed the other fields as well. That "Bummer, did you remove any of the provided code?" message is a hint that you changed more than the challenge was expecting.

For best results with the challenges, always follow the instructions carefully and avoid adding or changing anything not explicitly asked for.

But I do admire your initiative, and even if the challenge doesn't want to see it, it looks llike you did a good job completing the conversions. :+1:

Ohhh I see! Thanks a lot! I kinda have OCD on completing tasks so i was doing this for quite the good hour...