ASP.NET UpdatePanels and Lost Focus on new Controls
Posted on 2012-09-14
I have a Web USER Control that has 50 textbox’s on them I don’t want to have the user to ever be forced to hit a “Save” or “Submit” button. I want to have each edit change instantly recorded and stored in a database in my codebehind. (I can not use a webservice or database code in my client side scripts).
I tried wrapping each control in it’s own asp:UpdatePanel – the page doesn't flash anymore but there is a problem. When the user edits one textbox (say “TextBox1”) and then clicks on another textbox (say “TextBox2”), TextBox 2 does at first shows the edit cursor but after texbox1's autopostback / callback is called, TextBox2 loses focus and then the user must click on TextBox2 again to go back to editing.
I’ve read why this happens but I am trying to find a SIMPLEST way to solve this without having to rewrite the whole interface. I am assuming this can't be done with codebehind and I must use script. Does anyone know of an asp.net example using ajax codebehind and some easy script so that after the codebehind is called - the NEWLY focused textbox will be rendered with the focus which triggered the whole ajaxupdate to begin with?
Thanks in advance.