ASP.NET UpdatePanels and Lost Focus on new Controls

Hi

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.
vamail2Asked:
Who is Participating?
 
vamail2Connect With a Mentor Author Commented:
After researching forever on the web, I ended up just using JQuery and calls to code behind.
0
 
Padre_CorleoneCommented:
This might work ScriptManager.GetCurrent(this.Page).SetFocus(this.FirstNameTextBox)

stackoverflow.com/questions/1307224/setfocus-to-asptextbox-within-asppanel-within-aspcontent-from-content-page-lo
0
 
vamail2Author Commented:
Thank you for your help.   I realize it's a little tricky and I may not have explained it well.    

Your suggestion solution doesn't apply because it assumes I know the textbox that should get focus.  My issues is that I need to know which textbox got the focus and then reset it.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Padre_CorleoneCommented:
Ah ok well in that case you can save the textbox I'd in a hidden field with a runatserver property on click JavaScript.  Then you can find the textbox based on the hidden value textbox I'd in the code behind
0
 
vamail2Author Commented:
Ok.  Do you have a working example of a usercontrol  that does that?    I am assuming ally controls still have autopostback=true correct and this hidden button is just a method to store info who was focused.   Still not sure of what code I need where.  Would be grateful for real example.
0
 
Rajar AhmedConsultantCommented:
I realize it's a little tricky and I may not have explained it well.
You have explained well but without code its always difficult for us to understand completely.
Can u paste a sample code which can reproduce the issue for us .

Meeran03
0
 
vamail2Author Commented:
Hi.  How do I close this thread?
0
 
Amandeep Singh BhullarCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.