Adding images to a ListBox

  • Thread starter Michael Groeger
  • Start date
M

Michael Groeger

Hi,

is it possible to add an image to a item in a ListBox? I a searched all
around but couldn't find an answer for that?

Regards,
Michael
 
S

Scott Allen

Hi Michael:

Not from ASP.NET. If you absolutely need images in a ListBox control
you'll need to write a WinForms control that executes on the client's
machine.
 
M

Michael Groeger

Hi Scott,

thanks for your reply. That's really bad. But ok, than I have to do it by
myself or search for a control which brings that functionality.

Regards,
Michael
 
B

Bruce Barker

pretty trival markup:

<script>
function lc(e,v) {
document.getElementsByName(e)[0].value= v;
}
</script>
<div id="listbox1" style="height:100px;overflow:auto;border:1 solid black;">
<input type=hidden name="listbox1">
<table>
<tr onclick="lc('listbox1',1)"><td><img src="img1.gif">text1</td></tr>
<tr onclick="lc('listbox1',2)"><td><img src="img2.gif">text2</td></tr>
<tr onclick="lc('listbox1',3)"><td><img src="img3.gif">text3</td></tr>
<tr onclick="lc('listbox1',4)"><td><img src="img4.gif">text4</td></tr>
</table>
</div>

use a reapeater for databinding. left as exercise for the reader to toggle
style to show selected item, or to bundle as a control.


-- bruce (sqlwork.com)
 
M

Michael Groeger

Hi Bruce,

thanks for that. I will try that one out and do my exercises ;)

Regards,
Michael

Bruce Barker said:
pretty trival markup:

<script>
function lc(e,v) {
document.getElementsByName(e)[0].value= v;
}
</script>
<div id="listbox1" style="height:100px;overflow:auto;border:1 solid black;">
<input type=hidden name="listbox1">
<table>
<tr onclick="lc('listbox1',1)"><td><img src="img1.gif">text1</td></tr>
<tr onclick="lc('listbox1',2)"><td><img src="img2.gif">text2</td></tr>
<tr onclick="lc('listbox1',3)"><td><img src="img3.gif">text3</td></tr>
<tr onclick="lc('listbox1',4)"><td><img src="img4.gif">text4</td></tr>
</table>
</div>

use a reapeater for databinding. left as exercise for the reader to toggle
style to show selected item, or to bundle as a control.


-- bruce (sqlwork.com)

Michael Groeger said:
Hi,

is it possible to add an image to a item in a ListBox? I a searched all
around but couldn't find an answer for that?

Regards,
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top