Ayo Adesina
Ayo Adesina

Reputation: 2425

Adding a Class to @Html.DropDownList Razor

    @Html.DropDownList(productOption.Option.Id.ToString(), productOption.ValuesInOptions.ToSelectList(f => f.OptionValue.OptionValue1, 
                                               f => f.Id.ToString(), 
                                               "Select"));       

How would I add a class to the above @Html.DropDownlist() within a razor view?

Upvotes: 0

Views: 994

Answers (1)

Vsevolod Goloviznin
Vsevolod Goloviznin

Reputation: 12334

You can use it's overload, that accepts providing html attributes:

@Html.DropDownList(productOption.Option.Id.ToString(), productOption.ValuesInOptions.ToSelectList(f => f.OptionValue.OptionValue1, 
                   f => f.Id.ToString(), 
                   "Select"), new {@class = "some-class"});   

Upvotes: 3

Related Questions