tags:

views:

68

answers:

2

I have the most bizarre bug, where clicking a listbox item makes the listbox scroll down so that item is at the top. It's very annoying.

The listbox is in an updatepanel, so my best guess is when it posts back, asp.net remembers the selected index, populates the listbox, and then sets the selected index, causing it to scroll up until the selected index is on the screen.

Is there any way to stop it doing this? Perhaps it can remember how far down the scrollbar was...

A: 

Are you binding the contents of the listbox to a data source? If so, you may be rebinding it every time it posts back.

andypoi
A: 

My fault, it was triggering an updatepanel which in turn refreshed the original update panel, causing the contents to redraw and thus resetting the position of the listbox.

SLC