Arvind897
Arvind897

Reputation: 101

How to add tooltip for dropdown list items in Html.DropdownListFor MVC

I need to show tool tip for the values of the dropdown list items when using,

@Html.DropDownListFor(n => n.SomeProp, new SelectList(Source, "Id", "Name"));

Here source refers to a IEnumerable collection.

I believe we don't have title property here in MVC as compared to webforms.. Can you pls suggest?

Upvotes: 1

Views: 8098

Answers (1)

pinmonkeyiii
pinmonkeyiii

Reputation: 191

Little late on the response, but i'll throw my two cents in here just in case it could help answer it for someone else:

You should be able to pass the title property as an HTML attribute:

@Html.DropDownListFor(n=>n.SomeProp,
    new SelectList(Source, "Id", "Name"),new { @Title = "Tooltip here" })

http://msdn.microsoft.com/en-us/library/dd470329(v=vs.118).aspx

Upvotes: 4

Related Questions