This topic is locked
[SOLVED]

Stop autoscroll on add page

10/21/2025 11:54:17
ASPRunner.NET General questions
T
Tim author

Hello,

How can I prevent autoscroll to first control on an add page? I'd like it to stay at the top of the page. And is there a way to do this for just one page and/or for all pages?

Thanks,
Tim

ChatGPT 10/21/2025

Hello Tim,

In ASPRunner.NET, preventing the autoscroll to the first control on an add page can be accomplished using some custom JavaScript. Here’s how you can do this for a specific page or for all pages.

For a Specific Page

  1. Open your ASPRunner.NET project and navigate to the specific page where you want to disable the autoscroll.


  2. Go to the "Events" section of the page in the ASPRunner.NET interface.


  3. Add the following JavaScript code to the "Before Process" event:

    <script type="text/javascript">
    window.onload = function() {
    // Scroll to top of the page
    window.scrollTo(0, 0);
    };
    </script>

  4. Save and regenerate your project to apply the changes.



For All Pages

If you want to apply this to all add pages, you can place a similar script in the global header or footer of your application.

  1. Go to the "Settings" of your ASPRunner.NET project.


  2. Navigate to the "Header" or "Footer" section where you can add custom code that will be included on every page.


  3. Add the same JavaScript code there:

    <script type="text/javascript">
    window.onload = function() {
    // Scroll to top of the page
    window.scrollTo(0, 0);
    };
    </script>

  4. Save and regenerate your project to apply the changes.



Additional Notes

  • The above JavaScript code uses window.scrollTo(0, 0); to scroll to the top of the page when it loads.
  • You can customize the script further if you have other requirements or specific controls to focus on.
  • Make sure to test the implementation in different browsers to ensure compatibility.

If you have any further questions or need additional assistance, feel free to ask!

Best,
[Your Name]

T
Tim author 10/21/2025

ChatGPT got me close. I just added:

window.scrollTo(0, 0);

to JavaScript OnLoad event.

Thanks,
Tim