c# - DropDownList bootstrap styling -



c# - DropDownList bootstrap styling -

i'm new asp.net , have been working way through getting started asp.net mvc 5 tutorial on asp.net site.

i've come across problem can't seem style drop downwards box bootstrap. i'm using code below works displaying in standard drop downwards i'm unsure how styling work.

old code:

genre: @html.dropdownlist("moviegenre", "all")

edit:

@paul found solution:

@html.dropdownlist("moviegenre", (selectlist)viewbag.moviegenre, "select genre", new { @class = "form-control" })

thanks help everyone.

you need apply css class form-control. seek this:

@html.dropdownlist("moviegenre", "all", new { @class = "form-control"})

also seek dropdownlistfor, model property must explicitly set:

@html.dropdownlistfor(model => model.moviegenremodel, selectlist, new { @class = "form-control"})

thanks @paul correction.

you may have extend existing html control/update overload/constructor follows:

public static mvchtmlstring dropdownlist( htmlhelper htmlhelper, string name, ienumerable<selectlistitem> selectlist, string optionlabel, object htmlattributes // <--------------- need add together here )

for more help read mvc html helpers , take at:

stackoverflow: adding own htmlhelper in asp.net mvc showing enums in dropdownlist on our asp.net mvc view examining how asp.net mvc scaffolds dropdownlist helper drop downwards lists custom info elements stackoverflow: htmlattributes in extension method - bootstrap & mvc 5

another alternative take @ at twitterbootstrapmvc

c# css asp.net asp.net-mvc twitter-bootstrap

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -