解决方法
首先,我将焦点绑定在所有输入上并保留最后一个焦点控件ID.然后在UpdatePanel完成加载后,我将焦点设置为最后一个
// 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(); });
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。