I have an ASP.net WebForms page that has a lot of content on the top of the screen. It has a link button that will post back to the page and show another section of the page
I have
<asp:MultiView ID="mvAriza" runat="server">
<asp:View ID="View14" runat="server">
............ .......
</asp:View>
</asp:MultiView>
on *.aspx page. And on the *.aspx.cs page on a button click.
Page.SetFocus(mvAriza.ClientID);
It works great.
In your case I suggest you to keep the default value of Page.MaintainScrollPositionOnPostBack, and use the pure javascript scrolling function
function scrollToDiv()
{
document.getElementById('yourDiv').scrollIntoView();
}
And call it at the page startup with a little delay of 1ms (pure javascript again)
setTimeout(scrollToDiv, 1);
And finally call it from the C# code behind, with the RegisterStartupScript (js executed after all the page has been loaded) :
ScriptManager.RegisterStartupScript(Page, typeof(Page), "ScrollToADiv", "setTimeout(scrollToDiv, 1);", true);
Like this, it will bypass any asp automatic scrolling
Page.MaintainScrollPositionOnPostback = true
seems to work just fine.
You can use the code below if you have an anchor for the location:
Page.ClientScript.RegisterStartupScript(this.GetType(), "hash", "location.hash = '#MOVEHERE';", true);
This scroll automatically to desired Div in asp.net Control This is Function call it from Where you Want and also Download Java script file
OnClientClick="return scrollGrid()"
function scrollGrid1() { $('html,body').animate ( { scrollTop: $('#Div1').offset().top }, 'slow' ) }
Page.MaintainScrollPositionOnPostBack = true;
should take you back to the same position on the screen, but you could use AJAX, or you could use SetFocus()
to focus on a specific control after the postback:
http://msdn.microsoft.com/en-us/library/ms178232.aspx