views:

26

answers:

2

I have created a label and a dropdownlist. The label has the dropdownlist as associated id. If I click on the label and then uses the mouse up or down the dropdownlist creates a postback for each click. This is quite anoying and doesn't happen if you click on the dropdownlist and uses key-up or key-down, or if you uses another browser than IE.

Is it possibel to fix this, so you can use key-up and key-down without causing a postback, and first on the enter-key creates the postback (as it does if you click on the dropdownlist and not label)?

A: 

Set DropDownList.AutoPostBack to false.

David Neale
I don't want to disable autopostback. Like I wrote, I would like to be able use the key-up and down and then use the enter-key to cause the postback. This works if you click on the dropdownlist, but not on the label.
Dofs
That's the autopostback behaviour - http://www.dotnetspider.com/resources/189-AutoPostBack-What-How-works.aspx. I'd suggest writing some javascript to fire when the return key is pressed on the dropdownlist which calls __doPostBack.
David Neale
I choose to you use the javascript with __doPostBack, thanks!
Dofs
A: 

Set the AutoPostBack property to false. See the documentation.

Sani Huttunen