asp.net page trigger event panel scrollbar height invariable implementation method

  • 2021-01-22 05:04:26
  • OfStack

This article is to solve the asp.net page button click trigger event, the panel scroll bar is not automatically back to the top of the solution, for the page trigger 1 event, the panel scroll bar back to the top, do the following work every time to pull down 1, especially when selecting TreeView, this problem is very difficult, by this.MaintainScrollPositionOnPostBack = true; The enlightenment of the feeling.

The idea is to save the position of the ES11en scrollbar when clicked, and reassign it when loaded after the page-triggering event has completed. Make sure the page is saved every time you click, including all the buttons and other click events.

Steps:

1. The script


<head runat="server"> 
<title>asp.net Page-triggered event panel The height of the scroll bar does not change </title> 
<link href="Css/style.css" type="text/css" rel="stylesheet" /> 
<script type="text/javascript"> 
function setPanelScroll() 
{ 
document.getElementById('Hidden1').value = document.getElementById('Panel1').scrollTop; 
} 
</script> 
</head>

2.body


<body onclick="setPanelScroll()">

3. The assignment


function ViewObj(){document.getElementById('Panel1').scrollTop = document.getElementById('Hidden1').value;}window.onload = ViewObj;


Related articles: