I was wondering is there a way to list image and label using @Html.DropDownListFor helper in MVC razor? Something like this:
(source: dotnetspeaks.com)
I was wondering is there a way to list image and label using @Html.DropDownListFor helper in MVC razor? Something like this:
(source: dotnetspeaks.com)
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.
look here. It is jquery, it is easy to implement with a few lines
<link rel="stylesheet" type="text/css" href="../Scripts/msdropdown/dd.css" />
<script type="text/javascript" src="../Scripts/msdropdown/js/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="../Scripts/msdropdown/js/jquery.dd.js"></script>
<div>
<select name="webmenu" id="webmenu">
<option value="calendar" title="~/Content/Images/arrow.png">Calendar</option>
<option value="shopping_cart" title="~/Content/Images/SendtoFriend.jpg">Shopping Cart</option>
<option value="cd" title="~/Content/Images/facebook.png">CD</option>
<option value="email" title="~/Content/Images/Email.png">Email</option>
<option value="faq" title="~/Content/Images/VotePositive.png">FAQ</option>
<option value="games" title="~/Content/Images/VoteNegative.png">Games</option>
</select>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#webmenu").msDropDown();
});
</script>
In order to work. I have to changed a Little.. I prefer to use title
to show the image. It Works to me