Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html.DropDownList size attribute

This is HTML

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

This is Razor ( not sure if 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 image 302
Pete Davies Avatar asked Jul 09 '11 14:07

Pete Davies


1 Answers

Like this:

@Html.DropDownList(
    "yearList", 
    Enumerable.Empty<SelectListItem>(),  // <!-- TODO: bind with a real data
    new { 
        size = "25", 
        style = "width: 60px" 
    }
)
like image 117
Darin Dimitrov Avatar answered Sep 21 '22 09:09

Darin Dimitrov