Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

327
Visualizações
Scroll to anchor from code behind on button click, without postback

I have 3 buttons. When clicking them, different content is loaded from code behind. After the content is loaded, I need to scroll to the beginning of the content (MY-ANCHOR). This must be done without reloading the page. How can this be done?

Here is my code so far:

<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>

Code behind:

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"
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda