Maintain scroll position on postback in modal popup

A. Add 2 functions to store and set scroll position

1. storeScrollPositionEd(scrollValue) = save scroll position while scrolling
2. setScrollPositionEd() = set top position of div

<script type="text/javascript">
    function storeScrollPositionEd(scrollValue) {
        $('#<%=hfEdScrollPosition.ClientID%>').val(scrollValue);
    }
    function setScrollPositionEd() {
         $("#divEdScroll").scrollTop($('#<%=hfEdScrollPosition.ClientID%>').val());
    }
</script>    

B. Find the modal-body DIV name an Id and add onscroll function


<div id="divEdScroll" class="modal-body" onscroll="storeScrollPositionEd(this.scrollTop);">





C. Add a HiddenField to store scroll value

<asp:HiddenField ID="hfEdScrollPosition" runat="server" Value="0" />









D. call setScrollPositionEd() function after a postback



Comments

Popular posts from this blog

How to pay bonuses before salary payments

To Enable IIS HTTPS on your website