Joseph
Joseph

Reputation: 849

How to get Tooltip for selected item in DropDownListfor?

I couldnt find an attribute "title" for DropdownListFor and was wondering how to do the same for just the selected item in the dropdownlistFor. My code is

               @Html.DropDownListFor(m => m.objDetails.CategoryId, new SelectList(Model.objDetails.Categories, "CategoryId", "CategoryName"),  new { id = "cboCategory", style = "width:340px;"} )

Upvotes: 1

Views: 644

Answers (1)

Nilesh Gajare
Nilesh Gajare

Reputation: 6398

Source SO

The built-in DropDownList helper doesn't allow you for setting additional HTML attributes on individual options such as title. You will have to write your own custom helper if you want to achieve that. Here's one example

Upvotes: 1

Related Questions