Ajax UpdatePanels SetFocus issue
Posted
by George
on Stack Overflow
See other posts from Stack Overflow
or by George
Published on 2010-03-30T14:13:24Z
Indexed on
2010/03/30
14:23 UTC
Read the original article
Hit count: 316
I set the AutoPostback property of a textbox to True so I can process the TextChanged event on the server and, based on what they typed in the textbox, appropriately display a message in an update panel.
The problem is, when the partial screen refresh is performed, no control on the screen has focus.
99% of the time, when the text in the textbox is changed, it is because the user has tabbed forward, and so, to limit the disruption in the lost of focus, I perform a "Focus" call on teh next control in the tab sequence.
For the most part, this works OK, but of course, is disputive if the user is tabbing in the reverse order or has used the mouse to set the focus to another control. In these situations, the focus would be set to the next control even though the user was trying to set focus elsewhere.
OK, that sucks. Now what I consider the bigger problem with calling the focus method on the server:
In IE, it works OK, but in Mozilla Firefox and Chrome, setting the focus causes a repositioning of the scroll bar, even though none is necessary because the control is already in view.
I realize that I could switch to doing AJAX web service calls, but these darn Updae Panels are so convenient if used in moderation.
is there anyway to use updatepanels and not have these focus/scroll issues?
© Stack Overflow or respective owner