views:

28

answers:

1

I have an asp.net page with a list box on it. Multiple event handlers subscribe to its OnSelectedIndexChanged event.

When I change the SelectedIndex programmatically none of the events get fired.

Now a hack for this is to call each event handler, but this has already caused bugs since people didn't know they had to do this when adding a new event handler.

I can do this in a Winforms app and even when SelectedIndex is changed in code the events fire. Has anyone seen this before?

+1  A: 

Hi,

Take a look at the source code of the ListBox class and its base - ListControl. You will notice that the OnSelectedIndexChanged method is called from the RaisePostDataChangedEvent method. This means, that the SelectedIndexChanged event is only raised if the selected index was changed on the client side and the value stored in the ViewState does not equal data comes with the PostData. So, this event should not be raised if the SelectedIndex was changed in the server code.

DevExpress Team