asp.net - HTML.DropDownListFor 类分配

标签 asp.net class variable-assignment html.dropdownlistfor

是否可以将我自己的类分配给 HTML.DropDownListFor() 帮助器?

最佳答案

其中一个重载方法有一个对象 htmlAttributes 作为最后一个参数,您可以在其中指定要添加到生成的 html 中的额外属性:

Html.DropDownListFor(..., new { "class" = "myclassname" };

http://msdn.microsoft.com/library/ee703670.aspx

关于asp.net - HTML.DropDownListFor 类分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7970701/

相关文章:

asp.net - 子页面不从主页面获取样式

asp.net - Entity Framework 代码优先使用本地数据库,但部署到 Azure 时出错

asp.net - 字 rune 字中的字符太多?

c# - 使用类或函数

c - 将字节指针分配给 C 中的结构

java - 数字赋值应该抛出错误

c# - 为 Controller Action 参数创建过滤属性抗XSS攻击

java - 返回所有值的问题

c++ - 如何正确制作带有 templetad 数组的类对象?

json - Terraform:将包含字符串列表的变量传递到 jsonencode 部分