Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

319
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!