I need to Scroll Automatically to the Bottom of the Page when I click on the button. I have found lot of solutions on the forum but it don't work for me. I tried this in Java Script :
<asp:Button ID="btn_add_action1" runat="server" Text="Ajouter une action" onclick="btn_add_action1_Click" OnClientClick = "goToBottom()" />
With the JS function :
window.scrollTo(0,document.body.scrollHeight);
or
document.body.scrollTop = document.body.scrollHeight;
I found this here : Scroll Automatically to the Bottom of the Page
I tried many other solution but it don't work
When you click the button, a PostBack is performed. That means the scrolling position will be lost. If you want to scroll to the bottom of the page you have to do it after the PostBack is done, by using ScriptManager
protected void Button1_Click(object sender, EventArgs e)
{
//your button code
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "scrollDown", "setTimeout(function () { window.scrollTo(0,document.body.scrollHeight); }, 25);", true);
}
There is also something called MaintainScrollPositionOnPostBack
, that does something similar, it goes to the same position as the button click after PostBack.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments