What is the best way to reset the scroll position to the top of page after the an asynchronous postback?
The asynchronous postback is initiated from a ASP.NET Grid
Here is the following solution I developed based on this source
ASP.NET Webform
ASP.NET Webform code behind
protected void MyGridView_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType.Equals(DataControlRowType.DataRow))
{
foreach (DataControlFieldCell cell in e.Row.Cells)
{
foreach(Control control in cell.Controls)
{
LinkButton lb = control as LinkButton;
if (lb != null && lb.CommandName == "Edit")
lb.Attributes.Add("onclick", "SetScrollEvent();");
}
}
}
}