I created a select input field using the Razor. Given below is the code:
@Html.DropDownList("selectOption", new[] {
new SelectListItem()
{
Text ="Option 1" , Value = "1"
},
new SelectListItem()
{
Text = "Option 2" , Value = "2"
},
new SelectListItem()
{
Text = "Option 3" , Value = "3"
}
},
"Choose an Option...",
new {@class = "form-control" })
I am aware of adding custom class to select input field but how do I add custom class to each of the select options? Is it even possible using razor syntax?
I can get the results by using jQuery but I want to know whether there exists method using only razor.