Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

  1. Web.config Level => pages maintainScrollPositionOnPostBack="true" />

  2. Page Level => <%@ Page MaintainScrollPositionOnPostback="true" %>

  3. Code Level => Page.MaintainScrollPositionOnPostBack = true;

  4. Browser Level => browser id="Chrome" parentID="Safari1Plus"> capabilities> capability name="supportsMaintainScrollPositionOnPostback" value="true" /> capabilities> browser>

Any of the 4 ways mentioned above did not work with google chrome. It is working fine with firefox. Kindly provide any solution .

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

You can add this snippet to your ASP.NET Page/MasterPage (jQuery required):

<asp:HiddenField runat="server" ID="hfPosition" Value="" />
<script type="text/javascript">
    $(function () {
        var f = $("#<%=hfPosition.ClientID%>");
        window.onload = function () {
            var position = parseInt(f.val());
            if (!isNaN(position)) {
                $(window).scrollTop(position);
            }
        };
        window.onscroll = function () {
            var position = $(window).scrollTop();
            f.val(position);
        };
    });
</script>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...