mvc2のhtml.labelヘルパーにIDとText属性を設定したい
<%:html.label<have to set ID and Text properties here>%>
Plzは私を助けてくれます。
mvc2のhtml.labelヘルパーにIDとText属性を設定したい
<%:html.label<have to set ID and Text properties here>%>
Plzは私を助けてくれます。
Html.Labelメソッドは、指定された式で表されるHTML要素とプロパティのプロパティ名を返します。label
例えば:
<%: Html.Label("Text Content", new { id = "labelId" })%>
@Html.Label("Text Content", new { id = "labelId" })
2番目のパラメーターはhtmlAttributesであるため、この匿名オブジェクトのプロパティとして任意のhtml属性を追加できます。例えば:
new { id = "id-element", name = "name-element", size = 10, @class = "css-class" }
Id
htmlヘルパーメソッドを使用する場合は、次を使用してみてください。
@Html.IdFor(model => model.Property)