views:

330

answers:

1

I have a asp:ListBox wrapped inside an asp:UpdatePanel. The list box contains all the United States. If I select Alaska, for example, and then scroll down to select Wyoming, the listbox jumps back up to the top of the list instead of staying on Wyoming and it deselects Alaska, but Wyoming remains selected. Has anyone ran into this before?

+1  A: 

It sounds like you have the listbox set to autopostback. This would explain the jumping as the page or partial page (inside your Update Panel) gets reloaded.

As to deselecting the default choice (Alaska), this is default behavior. Only 1 option can be selected by clicking (even if you have SelectionMode set to multiple). To select multiple options, if enabled, you need to Ctrl-Click the options. This is browser/OS behavior you don't control directly.

HectorMac
You are correct, but in order for my listbox to generate the selected_index changed event, I need to enable autopostback.
Xaisoft
Well then you get what you have there. The UpdatePanel is no panacea. Sometimes you actually have to do some work.
Robert C. Barth
Thanks for that helpful comment.
Xaisoft