Reputation: 18746
one of the fields on my form is a textbox that the user types an id. this is the foreign key to another table so I need to bounce the data against that table before letting them submit. I'd rather not use textchanged as every letter they type may incur another query, focus lost would only show an error or validate when they are already in another field (not sure if it would fire if they just clicked submit).
I would prefer not to force someone's focus to stay in that field, but perhaps that's the best way?
Is there a method to sleep and wait to see if there is another incoming key event within X seconds? if so can I peek to see if it's a letter or number vs a tab or return?
Is there another event I should be hooking that's user friendly?
Should I pull down a copy of that column of the table and real time compare there? (I could handle adding a refresh button to pull a new cache)
Upvotes: 1
Views: 1797
Reputation: 49544
You may want to consider using a timer control for this.
Disable and Enable the control every time the key is pressed, to reset the timeout.
Then when the timer event fires, Disable the control and query the database.
EDIT: I still think your best bet is probably on the Lost Focus event.
Upvotes: 1