HTML.DropDownListFor 类分配
是否可以将我自己的类分配给 HTML.DropDownListFor() 帮助器?
Is it possible to assign my own class to the HTML.DropDownListFor() helper?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
其中一个重载方法有一个
object htmlAttributes
作为最后一个参数,您可以在其中指定要添加到生成的 html 中的额外属性:http://msdn.microsoft.com/library/ee703670.aspx
One of the overloaded method has an
object htmlAttributes
as last parameter in which you can specify extra attributes to be added to the generated html:http://msdn.microsoft.com/library/ee703670.aspx
Didier的答案大部分是正确的,但是要在htmlAttributes对象中定义类值,您需要使用以下语法:
“@”是让编译器知道这不是关键字“class”。使用
"class"
将导致编译错误。Didier's answer is mostly correct, but to define a class value in htmlAttributes object, you need to use this syntax:
The "@" is to let the compiler know that this is not the keyword "class". Using
"class"
will result in a compilation error.您可以使用以下任何逻辑。
或
或
You can use any of the below logic.
OR
OR