Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC Razor Dropdownlist with Image and label?

I was wondering is there a way to list image and label using @Html.DropDownListFor helper in MVC razor? Something like this:

a busy cat
(source: dotnetspeaks.com)

like image 324
TerryLi Avatar asked Mar 11 '13 22:03

TerryLi


2 Answers

There's nothing like this built into MVC, but I'm sure there are many 3rd-party components. I personally use dijit for this kind of thing, but since you have JQuery as one of your tags, you could probably use the Menu from JQuery UI.

like image 183
p.s.w.g Avatar answered Oct 18 '22 20:10

p.s.w.g


DropDownListFor renders a <select>. This HTML element does not support an image in the list. you will need to use a JavaScript library to get this effect. several of the libraries use a <select> as the basis (they hide the select but get values form it.) there are dozens of select replacement libraries.

Have a look at this tutorial, this will help you creating drop down list with images.

like image 36
Irfan Avatar answered Oct 18 '22 19:10

Irfan