To keep current scroll position after postback, use some jQuery and an ASP HiddenField.
1.) Add the HiddenField to the page:
2.) Add the Javascript (requires jQuery)
<script type="text/javascript">
$(function () {
var sp = $("#<%=ScrollPosition.ClientID%>");
window.onload = function () {
var position = parseInt(sp.val());
if (!isNaN(position)) {
$(window).scrollTop(position);
}
};
window.onscroll = function () {
var position = $(window).scrollTop();
sp.val(position);
};
});
</script>
No comments:
Post a Comment