I'm new to javascript and asp.net. I'm using linkbuttons in my page and when I click the buttons my page reloads and page scroll to the top.
I tried this script and it doesn't work.
<script type="text/javascript">
var xPos, yPos;
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
xPos = document.body.scrollLeft;
yPos = document.body.scrollTop;
}
function EndRequestHandler(sender, args) {
document.body.scrollLeft = xPos;
document.body.scrollTop = yPos;
}
</script>
只需在页面指令中添加MaintainScrollPositionOnPostback =“ true”
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.