I want to set ID and Text attribute in html.label helper in mvc2
<%:html.label<have to set ID and Text properties here>%>
Plz help me out..
The Html.Label method returns an HTML label
element and the property name of the property that is represented by the specified expression. For example:
<%: Html.Label("Text Content", new { id = "labelId" })%>
@Html.Label("Text Content", new { id = "labelId" })
The second parameter is the htmlAttributes, so, you can add any html attribute you want as a property of this anonymous object. For example:
new { id = "id-element", name = "name-element", size = 10, @class = "css-class" }
If you want to take the Id
by a html helper method, try to use:
@Html.IdFor(model => model.Property)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With