The Html.Label method returns the HTML label element and the name of the property property that is represented by the specified expression. For example:
ASPX Syntax
<%: Html.Label("Text Content", new { id = "labelId" })%>
Razor Syntax
@Html.Label("Text Content", new { id = "labelId" })
The second parameter is htmlAttributes, so you can add any html attribute that you want as a property of this anonymous object. For example:
new { id = "id-element", name = "name-element", size = 10, @class = "css-class" }
Idfor
If you want to take an Id using the html helper, try using:
@Html.IdFor(model => model.Property)
Felipe oriani
source share