问题描述
在剃刀引擎我已经使用 LabelFor
helper方法来显示名称
但显示名称似乎不是很好显示。
所以我需要改变我的显示名称怎么办呢......
@ Html.LabelFor(型号=> model.SomekingStatus,新{@class =控制标签})
您可以装饰用 [显示名称]
属性您的视图模型属性,并指定文字中使用
[DisplayName的(富巴)]
公共字符串SomekingStatus {搞定;组; }
或者使用LabelFor帮手,它允许你指定文字的另一重载:
@ Html.LabelFor(型号=> model.SomekingStatus,富巴)
和,不,你不能因为你试图做指定MVC3类名,作为 LabelFor
助手不支持。然而,这将工作在MVC4或5
In razor engine I have used LabelFor
helper method to display the name
But the display name is seems to be not good to display.so i need to change my display name how to do it....
@Html.LabelFor(model => model.SomekingStatus, new { @class = "control-label"})
You could decorate your view model property with the [DisplayName]
attribute and specify the text to be used:
[DisplayName("foo bar")]
public string SomekingStatus { get; set; }
Or use another overload of the LabelFor helper which allows you to specify the text:
@Html.LabelFor(model => model.SomekingStatus, "foo bar")
And, no, you cannot specify a class name in MVC3 as you tried to do, as the LabelFor
helper doesn't support that. However, this would work in MVC4 or 5.
这篇关于如何在剃刀MVC3更改显示名称LabelFor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!