As the title states, I wrote an ajax function that should scroll to the position the user were before getting redirected.
I wrote an alert
for test scenario and it does trigger but the scroll keeps getting back to the top, whave have I done wrong here?
JavaScript:
$.ajax({
type: "GET",
url: "AdminListUsers.aspx?column=Disabled&direc=False&a=chstat&z=+",
success: function loadDoc() {
window.scrollTo(window.pageXOffset, window.pageYOffset);
}
});
C#:
var toggleUrl = "AdminListUsers.aspx?column=" + (IsClicked.FirstOrDefault().Key ?? "Name") + "&direc=" + (IsClicked.FirstOrDefault().Value) + "&a=chstat&q=" + id.ToString() + "&d=" + disabled + "&z=" + Server.UrlEncode(txtSearchFor.Text);
var hl = new HyperLink();
hl.Text = status;
hl.Style.Add(HtmlTextWriterStyle.Color, (disabled ? "red" : "green"));
hl.NavigateUrl = toggleUrl;
hl.Attributes.Add("onclick", "loadDoc();return true;");
cell.Controls.Add(hl);
tr.Cells.Add(cell);