drop down menu - asp.net mvc How to add placeholder for html.dropdownlist -


i'm using asp.net mvc 3.

i have dropdownlist of countries , want add placeholder it. here's code:

@html.dropdownlist("country",      new selectlist(viewbag.countries system.collections.ienumerable,      "name", "name"), new { @class="chzn-select", @placeholder="-select-",      @style="width:160px;" } ) 

but placeholder doesn't work, while style works.

how set placeholder this?

ps. want use @html.dropdownlist, not @html.dropdownlistfor

in collection viewbag.countries insert dummy record @ of collection name "-select-". should able force selected item alternate constructor this:

@html.dropdownlist("country",      new selectlist(viewbag.countries system.collections.ienumerable,      "name", "name", "-select-"), new { @class="chzn-select", @style="width:160px;" } ) 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -