这是 HTML
<select size="25" style="width:100px" id="yearList"/>
这是 Razor (不确定这是否正确)
@Html.DropDownList("yearList", null, new{style="width:100px;"})
有谁知道如何给 Razor 版本一个类似于 HTML 版本的 size 属性?
非常感谢。
最佳答案
像这样:
@Html.DropDownList(
"yearList",
Enumerable.Empty<SelectListItem>(), // <!-- TODO: bind with a real data
new {
size = "25",
style = "width: 60px"
}
)
关于asp.net-mvc - Html.DropDownList 大小属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6635359/