Search code examples
asp.net-mvc-3razorscrollpostbackposition

ASP.NET MVC3 Razor - Maintain scroll position on postback


How can i maintain scroll position on postback after sorting a grid table that uses MvcContrib framework?


Solution

  • The usual way is to use some javascript to set the current scroll position to a hidden field, then restore that position on page load (usually in a jquery ready event).

    However, that's really just a side effect. You should be doing some kind of ajax command to update the grid rather than a postback, then no scrolling required.