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
204,019 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
204,019 Points

Oh, I assumed you had already passed task 2.

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