tengo 3 botones Al hacer clic en ellos, se carga contenido diferente desde el código subyacente. Después de cargar el contenido, debo desplazarme hasta el comienzo del contenido (MY-ANCHOR). Esto debe hacerse sin recargar la página. ¿Cómo se puede hacer esto?
Aquí está mi código hasta ahora:
<asp:UpdatePanel runat="server" ID="udpPolicy"> <ContentTemplate> <div class="row" id="MY-ANCHOR"> <div class="col"> <p> <div class="card"> <h4 class="card-header m-0"> <asp:Literal runat="server" ID="litTitle"/> </h4> <div class="card-body"> <asp:Literal runat="server" ID="litText"/> </div> </div> </p> </div> </div> <div class="row"> <div class="col"> <p> <asp:Button runat="server" ID="btnAgreement" Text="Agreement" OnClick="btnAgreement_OnClick" CausesValidation="False"/> <asp:Button runat="server" ID="btnPrivacy" Text="Privacy" OnClick="btnPrivacy_OnClick" CausesValidation="False"/> <asp:Button runat="server" ID="btnCookie" Text="Cookie" OnClick="btnCookie_OnClick" CausesValidation="False"/> </p> </div> </div> </ContentTemplate> </asp:UpdatePanel>Código detrás:
protected void btnAgreement_OnClick(object sender, EventArgs e) { litTitle = "Agreement title here"; litText = "Agreement text goes here..." // SCROLL TO "MY-ANCHOR" } protected void btnPrivacy_OnClick(object sender, EventArgs e) { litTitle = "Privacy title here"; litText = "Privacy text goes here..." // SCROLL TO "MY-ANCHOR" } protected void btnCookie_OnClick(object sender, EventArgs e) { litTitle = "Cookie title here"; litText = "Cookie text goes here..." // SCROLL TO "MY-ANCHOR" }