Question

I have a TextBox which has autopostback = true. I use the OnTextChanged event to query a database and show the results in a ListBox. ( this is where I make use of autopostback)

My problem is that when changing focus from the TextBox to select an item from the ListBox the postback event fires as in:

Use the AutoPostBack property to specify whether an automatic postback to the server will occur when the TextBox control loses focus. Pressing the ENTER or the TAB key while in the TextBox control is the most common way to change focus.

and the ListBox loses focus. Is there a way to avoid this behaviour?

EDIT:

For clarity:

The behaviour described above is wanted because I have a small JS function to remove and put the focus back on the TextBox so I can postback at TextChanged.

What I really want is to maintain the focus of the ListBox when removing it from the TextBox.

Was it helpful?

Solution

I found that the autopostback=true of the TextBox was not need since I was already doing postback with __doPostback() onkeyup. This alone alows me to handle the TextChanged Event of the TextBox.

By setting the property AutoPostBack of the TextBox control to false I removed redundant postback and removed the unwanted behaviour.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top