views:

13516

answers:

4

I have a server dropdownlist in an Ajax updatepanel. When I use the mouse to click on an item it fires the postback but when I click the up/down arrow to change entries, this is not firing. What could be reason?

A: 

I think you have to leave the control if you are using the keyboard in order to fire the event.

YonahW
is there anyway to have this fired right on the up/down arrow?
ooo
A: 

If you want it to work with the arrow keys, you should use the client side event, onKeyDown.

Paul Prewett
can you give me an example of how this would work . . and how this can then postback to the server for actions
ooo
+5  A: 

Try this:

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" onKeyUp="this.blur();">

With onKeyUp="this.blur();" the control will lose focus when a key is unpressed, and that will trigger the onChange event.

CMS
however nice this solution may be, you are killing functionality, if you have a list with 10 items, and the user decides to navigate by keyboard, he exits the dropdownlist every time he clicks up or down.is it possible to do onKeyUp="this.blur();this.focus();"?
Sander
A: 

Not sure this is what you are after but it may help.

Try setting the 'AutoPostBack' property of the DropDownList control to 'true'.

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true">
</asp:DropDownList>
David HAust