C# ASP.NET MVC Forms Creating a Basic Form Using HTML Helpers

I did this like the example in the video but I think I deleted something important

I am getting an error that states I might have deleted an important piece of markup

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

<h2>@ViewBag.Title</h2>

@using (Html.BeginForm())
{
<div class "form-group">
        @Html.Label("Name", new{@class = "control-label"})
        @Html.textbox ("Name", null, new{@class = form-control})
    </div>

    <div class "form-group">
        @Html.Label("Email", new{@class = "control-label"})
        @Html.textbox ("Email", null, new{@class = form-control})
    </div>

    <div class "form-group">

      @Html.Label("DepartmentId", new{@class = "control-label"})
        @Html.textbox ("DepartmentId", null, new{@class = form-control})
    </div>

    <div class "form-group">
      @Html.Label("Severity", new{@class = "control-label"})
        @Html.textbox ("Severity", null, new{@class = form-control})
    </div>

    <div class "form-group">       
      @Html.Label("Reproducible", new{@class = "control-label"})
        @Html.textbox ("Reproducible", null, new{@class = form-control})
    </div>

    <div class "form-group">

      @Html.Label("DescriptionOfProblem", new{@class = "control-label"})
        @Html.textbox ("DescriptionOfProblem", null, new{@class = form-control})
    </div>

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

}

3 Answers

Steven Parker
Steven Parker
204,019 Points

It looks like you may have done a bit more than was asked for:

  • the challenge said to " use the first method overload that accepts a single string parameter" to render the label, but your call is using two parameters.
  • the call to render the text box was similarly supposed to be the one-parameter version.
  • instead of "TextBox", you wrote "textbox" (all lower case)
  • the challenge only asked you to replace the label and input for the Name field, but you replaced them all.

in your answer to me what does this mean? --- the challenge said to " use the first method overload that accepts a single string parameter" to render the label, but your call is using two parameters.

Steven Parker
Steven Parker
204,019 Points

You wrote this:

        @Html.Label("Name", new{@class = "control-label"})
        //          -ONE--  -------------TWO-------------

As you can see from my comment, you are passing two parameters to the Label method. But the challenge says you should only have one.

Where did you get that extra parameter? Did you just cut and paste that from some other part of the lesson? You can be pretty sure that the challenges will NOT just ask you to repeat stuff done in the lesson.

ok I was able to solve the problem thank you