Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9185637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:19:32+00:00 2026-06-17T19:19:32+00:00

I am trying to do infinite scroll in my .NET website, using javascript and

  • 0

I am trying to do infinite scroll in my .NET website, using javascript and the following sql statement (sql server 2008). This sql gets the first 10 rows, but my javascript causes the sql to execute each time the user scrolls to the bottom of the page, and each time, it pulls the same (first 10) records, but I want it to pull the NEXT 10 records, each time user scrolls to the bottom. How do I use this sql and row_number to get the NEXT 10 rows, each time user scrolls to bottom of page?

SELECT * FROM 
  (SELECT ROW_NUMBER() OVER (ORDER BY DateTime) As RowNum, 
  * From Topic) As a 
WHERE RowNum 
BETWEEN 1 AND 10

Here is the javascript:

<script type="text/javascript">
        $(document).ready(function () {

       function lastPostFunc() {
           $('#divPostsLoader').html('<img src="images/bigLoader.gif">');

           //send a query to server side to present new content
           $.ajax({
               type: "POST",
               url: "Default.aspx/Foo",
               data: "{}",
               contentType: "application/json; charset=utf-8",
               dataType: "json",
               success: function (data) {

                   if (data != "") {
                       $('.divLoadData:last').after(data.d);
                   }
                   $('#divPostsLoader').empty();
               }

           })
       };

       //When scroll down, the scroller is at the bottom with the function below and fire the lastPostFunc function
       $(window).scroll(function () {
           if ($(window).scrollTop() == $(document).height() - $(window).height()) {
               lastPostFunc();
           }
       });

    });
</script>

I now have the above sql in stored procedure:

<System.Web.Services.WebMethod()>
Public Shared Function Foo() As String
    Dim strConn As String = "Data Source="
    Dim conn As New SqlConnection(strConn)
    Dim Cmd As New SqlCommand("InfiniteScroll", conn)
    Cmd.CommandType = CommandType.StoredProcedure
    Dim DA As New SqlDataAdapter(Cmd)
    Dim DS As New DataSet()
    DA.Fill(DS, "RefologyForumTopic")
    Dim getPostsText As New StringBuilder()
    Dim dv As DataView = DS.Tables(0).DefaultView

    For Each myDataRow As DataRowView In dv
        getPostsText.AppendFormat("price: {0}</br>", myDataRow("Topic"))
        getPostsText.AppendFormat("description: {0}</br></p>", myDataRow("UserID"))
    Next

    getPostsText.AppendFormat("<div style='height:15px;'></div>")
    Return getPostsText.ToString()
End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:19:33+00:00Added an answer on June 17, 2026 at 7:19 pm

    Typically we do this using a stored procedure passing in a page and/or result counter parameters. Something like this:

    SELECT * 
    FROM (
       SELECT ROW_NUMBER() OVER (ORDER BY DateTime) As RowNum, * 
       FROM Topic) As a 
    WHERE RowNum BETWEEN 1+(@recsPerPage)*(@page-1) AND @recsPerPage*(@page)
    

    Here is the SQL Fiddle.

    –EDIT

    This is all untested, but should get you going in the right direction:

    First, add a hidden page to the page to store your current page number:

    <input type=hidden id=hidPage name=hidPage value="1">
    

    Second, update your data parameters in your ajax call:

    data: { Page: $("#hidPage").value() },
    

    Third, update your web method to accept the param:

    Public Shared Function Foo(page as string (or int -- would need to test for sure)) As String
    

    Then update your SQL to pass the parameter. I’m not going to rewrite that, but use this link for assistance: http://msdn.microsoft.com/en-us/library/bbw6zyha(v=vs.71).aspx

    And finally, reset your hidPage variable on your ajax success handler.

    var newPage = parseInt($("#hidPage").val());
    $("#hidPage").val(newPage+1);
    

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use this function for infinite scroll: <script type=text/javascript charset=utf-8> (function() {
I'm trying to add infinite scroll functionality to a page using code given in
So I'm trying to create an infinite scrolling table using AngularJS, similar to this:
I'm using the infinite scroll jquery plugin for a website ( https://github.com/paulirish/infinite-scroll ) Everything
I'm trying to use the infinite scroll AS3 I discuss in this SO question
I am using Doctrine and trying to implement an infinite scroll on a collection
I am trying to make this infinite scroll script work the way i want.
I am experimenting with this: http://dev.sencha.com/deploy/ext-4.0.0/examples/grid/infinite-scroll.html I'm trying to make it possible for the
Hi I am trying to setup a site using jQuery Masonry and Infinite scroll
I have been trying infinite scroll for my own website. It is working fine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.