Question

i have div with max height and overflow - auto, when div size overflows scroll bar added automatically, but i set

$("#itemsdiv").scrollTop(10000); 

so that scroll bar is always at bottom . Now i want that if view is load with ajax request then scrollbar is at bottom , and if view load when page refreshing then scroll bar will at top of div. can any one help me

thank you

Was it helpful?

Solution

@if(Request.IsAjaxRequest())
 {
     <script>        
    //If Ajax Request Code Here
   $("#itemsdiv").scrollTop(10000);
   </script>
 }
 else
 {
    <script>//Else here
    $("#itemsdiv").scrollTop(10);
   </script>
 }

Put the Above code in your View

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top