Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

138
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda