开发者

Html.DropDownList size attribute

开发者 https://www.devze.com 2023-03-19 14:00 出处:网络
This is HTML <select size=\"25\" style=\"width:100px\" id=\"yearList\"/> This is Razor ( not sure if开发者_StackOverflow中文版 this is the correct term)

This is HTML

<select size="25" style="width:100px" id="yearList"/>

This is Razor ( not sure if开发者_StackOverflow中文版 this is the correct term)

@Html.DropDownList("yearList", null, new{style="width:100px;"})

Does anyone know how to give the Razor version a size attribute similar to the HTML version?

Many thanks.


Like this:

@Html.DropDownList(
    "yearList", 
    Enumerable.Empty<SelectListItem>(),  // <!-- TODO: bind with a real data
    new { 
        size = "25", 
        style = "width: 60px" 
    }
)


open /Content/Site set the select class with the width, this will automatically be reflected on your page

select
{
    width:250px;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消