tags:

views:

185

answers:

2

Hi all,

I need to have a dropdownlist whose options contains text followed by a small image.

Suppose I have a dropdownlist of fruits. I want to show the options as :

Option 1 : small Image of mango then text Mango

Option 2 : small Image of orange then text Orange .....................

Is it possible to implement in asp.net 2.0?

If yes then please help with sample code.

I don't want to use JQuery.

+1  A: 

You can do that server side by just placing <asp:Image ImageUrl="some.gif" /> tags in your ASP.NET code. The browser will show them when the page is loaded.

jaywon
A: 

You don't need to use JQuery, use CSS background-image property for every <option>.

Soufiane Hassou
@Soufiane Is such a thing also possible with JSP/HTML/JS/CSS ??
akjain
It is working in Firefox but not in IE6. I have tried the following css: option{background-image:url('smp.png');margin-left:10px;padding-left:60px;background-repeat:no-repeat;height:30px;}
Himadri
@akjain: the server-side technology is irrelevant in this case, so yes, it'll work since it's just CSS.
Soufiane Hassou
@Himadri: Apparently, it's not possible in IE6, but you still can do it by "simulating" a select using div/span.
Soufiane Hassou
IE6 can do it, but has problems with png's. If it doesn't have to be a .png I would suggest making it a .gif or .jpg. If it has to be a .png, do a Google search on "iepngfix.htc" to find tutorials on how to have IE6 display them properly.
jaywon

related questions