asp.net WebForm_AutoFocus函数改变了我的文档滚动位置 [英] asp.net WebForm_AutoFocus function changes my document scroll position
问题描述
我正在使用带有Ajax功能的ASP.NET构建Web应用程序。
在我的应用程序中,我不希望在回传后回复文档滚动位置。我已将Web.Config中的maintainScrollPositionOnPostBack设置为true。但是,不知怎的,它不起作用。
I am building a web Application using ASP.NET with Ajax functionality.
In my Application, I don't want the document scroll position to be changed after a patial postback. I have set maintainScrollPositionOnPostBack in Web.Config to "true". But, somehow it's not working.
<pages maintainScrollPositionOnPostBack="true" >
<controls>
<add tagPrefix="ig" src="~/Controls/SOAGrid.ascx" tagName="ExcelGrid"/>
<add tagPrefix="ig" src="~/Controls/IgMenu.ascx" tagName="IgMenu"/>
<add tagPrefix="ig" src="~/Controls/IgList.ascx" tagName="IgList"/>
</controls>
</pages>
然后,我尝试使用Javascript / Jquery存储scrollTop位置,并在回发完成后将其设置回来。
Then, I tried Javascript/Jquery to store the scrollTop position, and set it back after the postback is finished.
var bodyScrollTop = 0;
function BeginRequestHandler(sender, args) {
bodyScrollTop = $(document).scrollTop();
}
function pageLoad() {
$(document).scrollTop(bodyScrollTop);
}
但是,这也无效。我发现有一些javascript方法,即scriptResource.axd,它运行在我的所有脚本之后。在这个脚本中,有一个代码WebForm_AutoFocus,它重置了我的文档滚动位置。请为我建议一个解决方案。
But, this is also not working. I found out there are some javascript methods namely scriptResource.axd which run after all my scripts. In this script, there is a code WebForm_AutoFocus which resets my document scroll position. Please suggest me a solution for this.
推荐答案
(document).scrollTop();
}
function pageLoad(){
(document).scrollTop(); } function pageLoad() {
(document).scrollTop(bodyScrollTop);
}
(document).scrollTop(bodyScrollTop); }
但是,这也无效。我发现有一些javascript方法,即scriptResource.axd,它运行在我的所有脚本之后。在这个脚本中,有一个代码WebForm_AutoFocus,它重置了我的文档滚动位置。请为我建议一个解决方案。
But, this is also not working. I found out there are some javascript methods namely scriptResource.axd which run after all my scripts. In this script, there is a code WebForm_AutoFocus which resets my document scroll position. Please suggest me a solution for this.
这篇关于asp.net WebForm_AutoFocus函数改变了我的文档滚动位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!