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

Fahmi Eshaq
Fahmi Eshaq
3,002 Points

Error: Did you remove any of the provided field markup

Edited: In Report.cshtml render the <label> element for the "Name" field using the Html.Label method. The label isn’t using any CSS classes, so you can use the first method overload that accepts a single string parameter for the expression to identify the property to display (MvcHtmlString HtmlHelper.Label(string expression)).

I don't see what I did wrong!

@{ ViewBag.Title = "Report an Issue"; }

<h2>@ViewBag.Title</h2>

@using(Html.BeginForm()) { <div> @Html.Label("Name") <input type="text" id="Name" name="Name" /> </div>

<div>
    @Html.Label("Email")
    <input type="text" id="Email" name="Email" />
</div>

<div>
     @Html.Label("DepartmentId")
    <input type="text" id="DepartmentId" name="DepartmentId" />
</div>

<div>
     @Html.Label("Severity")
    <input type="text" id="Severity" name="Severity" />
</div>

<div>
     @Html.Label("Reproducible")
    <input type="text" id="Reproducible" name="Reproducible" />
</div>

<div>
    @Html.Label("DescriptionOfProblem")
    <textarea id="DescriptionOfProblem" name="DescriptionOfProblem"></textarea>
</div>

}

Report.cshtml
@{
    ViewBag.Title = "Report an Issue";
}

<h2>@ViewBag.Title</h2>

@using(Html.BeginForm())
{
    <div>
        @Html.Label("Name")
        <input type="text" id="Name" name="Name" />
    </div>

    <div>
        @Html.Label("Email")
        <input type="text" id="Email" name="Email" />
    </div>

    <div>
         @Html.Label("DepartmentId")
        <input type="text" id="DepartmentId" name="DepartmentId" />
    </div>

    <div>
         @Html.Label("Severity")
        <input type="text" id="Severity" name="Severity" />
    </div>

    <div>
         @Html.Label("Reproducible")
        <input type="text" id="Reproducible" name="Reproducible" />
    </div>

    <div>
        @Html.Label("DescriptionOfProblem")
        <textarea id="DescriptionOfProblem" name="DescriptionOfProblem"></textarea>
    </div>
}

1 Answer

Steven Parker
Steven Parker
231,198 Points

:point_right: You appear to have done something other than the challenge task.

Task 3 of the challenge asks you to "render the <input> element for the "Name" field using the Html.TextBox method.".

But instead of changing just the first input, it looks like you changed all the other labels instead.

Fahmi Eshaq
Fahmi Eshaq
3,002 Points

This is the question:

In Report.cshtml render the <label> element for the "Name" field using the Html.Label method. The label isn’t using any CSS classes, so you can use the first method overload that accepts a single string parameter for the expression to identify the property to display (MvcHtmlString HtmlHelper.Label(string expression)).

Fahmi Eshaq
Fahmi Eshaq
3,002 Points

Resolved. Thanks Steven

Steven Parker
Steven Parker
231,198 Points

Oh, I assumed you had already passed task 2.

Yes, task 2 is about changing the label. But just that first label. :wink: