[英]How to set ID and Text in html.label helper in mvc2
I want to set ID and Text attribute in html.label helper in mvc2 我想在mvc2中的html.label帮助器中设置ID和Text属性
<%:html.label<have to set ID and Text properties here>%>
Plz help me out.. Plz帮帮我..
The Html.Label method returns an HTML label
element and the property name of the property that is represented by the specified expression. Html.Label方法返回HTML label
元素以及由指定表达式表示的属性的属性名称。 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. 第二个参数是htmlAttributes,因此,您可以添加任何您想要的html属性作为此匿名对象的属性。 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帮助方法获取Id
,请尝试使用:
@Html.IdFor(model => model.Property)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.