Search code examples
asp.net-mvchtml.label

What is the proper use of the Html.Label?


What is the proper use of this field html helper???

I have the below code in my View, but when displayed it doesn't appear how I expect.

<td><@Html.Label("lblLoanType1", "Loan Type : ")</td>
<td><@Html.Label("lblLoanType2", "SBA")</td>

Here is the output when displayed in the View:

<Loan Type :                       <SBA

Solution

  • You have an extra < before @Html that is not necessary

    <td><@Html.Label
    

    should just be

    <td>@Html.Label
    

    Then the rest of the appearance is down to your css.