2011-11-06 84 views
2

我想建立一个文本区像这样的MVC剃刀页:如何在剃须刀页面上干净地设置htmlattributes?

@Html.TextAreaFor(e => e.Description) 

但我没有的设置对超负荷的htmlattributes在页面上此方法的整洁方式的想法。或者我可以在模型上做到这一点?

知道如何去做这两种方法将是非常好的:-)

回答

6

喜欢的东西,

@Html.TextAreaFor(e => e.Description, new { yourattribute = "Hello" }) 

这是一个匿名类型。如果你需要用语言的关键字,例如class,以@逃避它:

@Html.TextAreaFor(e => e.Description, new { @class = "yourCSSclass", yourattribute = "Hello" }) 
+0

感谢这就是伟大的,是有可能的模型设定吗? – Exitos

+0

@退出 - 开箱即用,不,我不相信这是可能的。 – vcsjones