如何改变html.DropDownListFor()的宽度

Pet*_* M. 11 asp.net asp.net-mvc asp.net-mvc-2

我有一个小的设计问题

html.DropDownListFor() 
Run Code Online (Sandbox Code Playgroud)

我怎样才能改变宽度html.DropDownListFor()?例如通过css.

谢谢你的回答

gri*_*egs 16

你有没有尝试过 Html.DropDownListFor( new {width:"100"})

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

编辑

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

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


iLe*_*ing 12

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

会做的事情.虽然更好地使用css类