views:

233

answers:

1

Hi

I have an ASP.NET page with a listbox whose selection mode is set to multiple by default. I would like to set its selection mode to single on a button click.

Code snippet of my attempt:

$('#testBtn').click(function(){        
      $('#testListBox').attr("SelectionMode","Single");
});

It is not working though. What am I doing wrong here and how to get it to work?

cheers

+3  A: 

The select box uses the attribute "multiple" to determine if it should allow multiple selections. You can remove it via jQuery using the removeAttr() function:

$('#testListBox').removeAttr('multiple');
Owen