How do I maintain scroll position in MVC?

后端 未结 12 1922
情歌与酒
情歌与酒 2020-11-27 18:02

Im working on a project in MVC and have enjoyed learning about it. There are a few growing pains but once you figure them out it\'s not bad. One thing that is really simpl

12条回答
  •  失恋的感觉
    2020-11-27 18:27

    Actually there is no standard way of handling this, this was a Microsoft hack to support their post back model. They needed this because every control did a post back and the user would constantly be pushed back to the top of the page.

    The recommendation for use with MVC is to do most of your post back to servers using AJAX. So that the page doesn't have to rerender the the focus is not moved. jQuery makes AJAX really easy, and there is even default forms like

    <% Ajax.BeginForm(...) %>
    

    Which will take care of the AJAX side of things for you.

提交回复
热议问题