First I snap the focus to all inputs and keep the last focused control identifier. Then, after UpdatePanel completes the download, I set the focus to the last
// keep here the last focused id var LastFocusedID = null; function watchTheFocus() { // on every input that get the focus, I grab the id and save it to global var $(":input").focus(function () { LastFocusedID = this.id; }); } var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_initializeRequest(InitializeRequest); prm.add_endRequest(EndRequest); function InitializeRequest(sender, args) { } // after the updatePanel ends I re-bind the focus, and set the focus // to the last one control function EndRequest(sender, args) { if(LastFocusedID != null) $('#' + LastFocusedID).focus(); watchTheFocus(); } jQuery(document).ready(function() { watchTheFocus(); });
I only think that I use jQuery to create it, but I present my idea here, you can do it with less code with jQuery.
source share