asp.net-mvchtml.label

How to get value from model for Html.Label?


I want to place the value of a field (property) from model into Html.Label. Something like this:

@Html.Label(item => item.Title)

I don't want a label for item.Title (like Html.LabelFor( model => model.Title)). But I want to put the value of item.Title in the label as text (string). So the result in run-time should be like this:

<label>Some Title</label>

How can I do this?


Solution

  • Try this:

    @Html.Label(Model.Title)
    

    It should work

    EDITED

    or this:

    <label>@Html.DisplayFor(item => item.Title)</label>