Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
Webpage scrolls up when button is clicked

I'm building a webpage with ASP.net where, when the button at the top of the page, it automatically scrolls down to a certain :

<script>
      function myFunction() {
         const element = document.getElementById("Results");
         element.scrollIntoView({behavior: 'smooth'});
      }
</script>

But unfortunately, it goes back up again after the click. I have tried a number of solutions, like:

<script type="text/javascript">
 var xPos, yPos;
 var prm = Sys.WebForms.PageRequestManager.getInstance();
 prm.add_beginRequest(BeginRequestHandler);
 prm.add_endRequest(EndRequestHandler);
 function BeginRequestHandler(sender, args) {
     xPos = $get('scrollDiv').scrollLeft;
     yPos = $get('scrollDiv').scrollTop;
 }
 function EndRequestHandler(sender, args) {
     $get('scrollDiv').scrollLeft = xPos;
     $get('scrollDiv').scrollTop = yPos;
}
</script>

or

MaintainScrollPositionOnPostback="true"

but to no avail.

My button is coded as:

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" 
        OnClientClick="myFunction()" Visible="true" Style="display: none" />

What other solutions should I try to implement?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!