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