How to change width of html.DropDownListFor()

浪尽此生 提交于 2019-12-04 01:46:13

Have you tried Html.DropDownListFor( new {width:"100"})

or Html.DropDownListFor( new {@class:"longDropdownList"})

EDIT

<style>
    .MakeWide { width: 200px; }
</style>

<%= Html.DropDownListFor(x => x.Name, new SelectList(new List<string>()), new { @class = "MakeWide" })%>

@Html.DropDownListFor(x => x.Name, new SelectList(new List<string>()), new {style="width:270px;"} );

Will do the thing. Although better to use css class

h.boulla

In C# you need add @, like this:

new { @style = "width: 350px;" }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!