如何在剃刀页面上干净地设置htmlattributes?

Exi*_*tos 2 asp.net-mvc-3

我想在MVC剃刀页面上设置一个文本区域,如下所示:

@Html.TextAreaFor(e => e.Description)
Run Code Online (Sandbox Code Playgroud)

但我不知道在页面上为此方法设置重载的htmlattributes是一种整洁的方法.或许我可以在模特身上做到这一点?

知道怎么做这两种方式真的很好:-)

vcs*_*nes 6

就像是,

@Html.TextAreaFor(e => e.Description, new { yourattribute = "Hello" })
Run Code Online (Sandbox Code Playgroud)

这是一种匿名类型.如果您需要使用语言关键字,例如class,使用@转义它:

@Html.TextAreaFor(e => e.Description, new { @class = "yourCSSclass", yourattribute = "Hello" })
Run Code Online (Sandbox Code Playgroud)