I want to scroll to top if there is an error on postback of a button click. I am working on asp.net C#. I am using following method to scroll to top.
.cs code on page_load method
if (IsPostBack)
{
System.Web.UI.ScriptManager.RegisterStartupScript(Page, this.GetType(), "ScrollPageLogin", "ResetScrollPositionLogin();", true);
}
.ascx code for jquery call
function ResetScrollPositionLogin()
{
$('html, body').animate({ scrollTop: 0 }, 'fast');
}
When I use this code and click on login button then it scroll to the down first and then scroll to up. Please help me to resolve this.