I'm working on web project in MVC 3 with Razor c#.
I have used @Html.DropDownListFor that display item dynamically. I want to set tooltip for every item of @Html.DropDownListFor.
My line of code as below
@Html.DropDownListFor(m => m.Type, new SelectList(Model.Types, "Value", "Text", Model.Type),
new { @class = "Type"})
You can't do it out of the box. One way is to use js described in this answer.
The other opportunity is to create your own Type like
SelectListItem, but withTitleproperty and createEditorTemplatefor your Type. For this variant i provide some code:Your Templave ViewModel:
Your EditorTemplate that you should place in
/Views/Shared/EditorTemplateswith nameSelectListWithTitle.cshtmlYour ViewModel like this:
Your controller:
And your View Index:
Don't forget to change your namespaces.