Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP:ListBox | Multi Select | Keep selected values when selecting a new one

1) Have a listbox with 3 values out of 5 selected

2) When I click to select another value without holding CTRL button, it will unselect over values

How to make it keep other selected values if new value is selected?

like image 762
Chicago Avatar asked Nov 20 '25 02:11

Chicago


1 Answers

This is going to sound like a snide answer, but I don't mean it that way. I just like to look for the simple solutions rather than the complicated onces.

The easiest way to get a control to have the behavior you want is to use a control that has the behavior that you want, rather than modifying the behavior of an existing control.

That said, if you want a list of items where a user can select a bunch of items off the list, and don't want to have to rely on them holding control, you're using the wrong tool for the job.

Use a CheckBoxList instead of a ListBox. If you want it to be scrollable, then set it in a div of a specific height, and set the style of the div to "overflow: scroll".

like image 118
David Avatar answered Nov 22 '25 17:11

David