Encountering a problem with page scrolling behavior in an ASP.Net web forms application when using Bootstrap CSS. Here's what's happening:
- Started a new Web Forms project in Visual Studio 2022
- Visual Studio set up the project with necessary folders/files & packages (including Bootstrap 5.2)
- On the default.aspx page, placed an
asp:Button
inside anasp:UpdatePanel
, linked to a JavaScript function on client click. The button is supposed to scroll to adiv
at the bottom of the page.
<asp:UpdatePanel ID="upd" runat="server"> <ContentTemplate> <asp:Button ID="btn" runat="server" Text="Button 1" OnClientClick="Scroll()" /> </ContentTemplate> </asp:UpdatePanel> <div id="div1" style="background-color:aquamarine"> Scrolled </div> <script> function Scroll() { /*location.href = '#div1';*/ <%--document.getElementById("<%=div1.ClientID %>")--%> document.getElementById("div1").scrollIntoView(); } </script>
- Upon testing, noticed that the page initially scrolls to the bottom as expected but then quickly jumps back to the top.
Seeking assistance based on the following observations:
Observations
- If the reference to Bootstrap CSS below is disabled, the functionality works correctly without any issue.
<webopt:bundlereference runat="server" path="~/Content/css" />
- Visit the link below to access videos and full source code