How to change width of html.DropDownListFor()

前端 未结 3 975
我在风中等你
我在风中等你 2021-02-20 03:02

I have small design question about

html.DropDownListFor() 

How can I change width of html.DropDownListFor() ?? For example by css.

相关标签:
3条回答
  • 2021-02-20 03:08

    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" })%>
    
    0 讨论(0)
  • 2021-02-20 03:08

    In C# you need add @, like this:

    new { @style = "width: 350px;" }
    
    0 讨论(0)
  • 2021-02-20 03:27

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

    Will do the thing. Although better to use css class

    0 讨论(0)
提交回复
热议问题