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 8678719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:47:40+00:00 2026-06-12T20:47:40+00:00

I am trying to get jsRender and paging to work, but I am somewhat

  • 0

I am trying to get jsRender and paging to work, but I am somewhat new to jsRender and jquery for that matter.
I have tried to modify this to work with jsRender instead, but I am having only limited success.

  1. I am getting an exception when I click the “next page” link (see the code). The exception is “JsRender Error: Unknown template: “#items” – I think it happens because the code is overwritten on subsequent data fetch, but I am not sure how to fix it – any help is appreciated.
  2. Can anybody suggest some hints to create a numeric paging mechanism as well? E.g. “<< 1 2 3 4 5 6 7 8 9 10 … >> – clicking on the “…” will reset the numerics to “<< 11 12 13 ..” and so on.

Here is my code for paging.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="paging.aspx.cs" Inherits="paging" EnableViewState="true" %>
<html>
<head>
<style type="text/css">
    body,table {font-family: Verdana; font-size:12px;}
    th,td {text-align:left;}
    div.paging a {padding:0 3 0 3;}
</style>

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>  
<script src="/js/jsrender.js" type="text/javascript"></script>

<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        loadData(1);
        loadCount();
    });

    function loadData(page) {
        $.ajax({
            type: "POST",
            url: "paging.aspx/getData",
            data: "{'Page':'" + page + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                updatedata(msg);
                UpdatePaging();
            }
        });
    }

    function loadCount() {
        $.ajax({
            type: "POST",
            url: "paging.aspx/ItemCount",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                lastPage = Math.ceil(msg.d / 10);
                UpdatePaging();
            }
        });
    }

    var currentPage = 1;
    var lastPage = 3;

    function UpdatePaging() {
        if (currentPage != 1) {
            $('#PrevPage').attr('href', '#');
            $('#PrevPage').click(PrevPage);
        }
        if (currentPage != lastPage) {
            $('#NextPage').attr('href', '#');
            $('#NextPage').click(NextPage);
        }
    }

    function NextPage(evt) {
        evt.preventDefault();
        DisplayProgressIndication();
        loadData(++currentPage);
    }

    function PrevPage(evt) {
       evt.preventDefault();
       DisplayProgressIndication();
       loadData(--currentPage);
    }

    function DisplayProgressIndication() {
        // Hide both of the paging controls,
        //  to avoid click-happy users.
        $('.paging').hide();
        // Clean up our event handlers, to avoid memory leaks.
        $('.paging').unbind();
    }

</script>
</head>
<body>

<table>
<thead>
    <tr><th>Title</th><th>Date</th><th>ID</th></tr>
</thead>
<tbody id="list">
    <script id="items" type="text/x-jsrender">        
    <tr>     
    <td>{{>Title}}</td>
    <td>{{>Date}}</td>
    <td>{{>ID}}</td>
     </tr>
    </script>
</tbody>
</table>

    <script type="text/javascript">
        function updatedata(msg) {
            $("#list").html($("#items").render(msg.d));
        }
     </script>

<br />

<a id="PrevPage" class="paging">&laquo; Previous Page</a>
<a id="NextPage" class="paging">Next Page &raquo;</a>

</body>
</html>

The paging.aspx.cs looks like this:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;
using System.Web.Services;


public partial class paging : System.Web.UI.Page
{
    static int pageSize = 10;
    static int totalRows = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    [WebMethod]
    public static IEnumerable getData(int Page)
    {
        DataTable dt = DataAccess.returnList(Page, pageSize);
        var data = from d in dt.AsEnumerable()
                   select new
                   {
                       Title = d.Field<string>("Title"),
                       ID = d.Field<int>("ID"),
                       Date = d.Field<DateTime>("Date").ToString()
                   };
        totalRows = int.Parse(dt.Rows[0]["TotalRows"].ToString());
        return data;
    }

    [WebMethod]
    public static int ItemCount()
    {
        return totalRows;
    }
}

The json data I get back looks like this in raw request:

{"d":[{"Title":"Bla bla","ID":123,"Date":"04-07-2012 10:05:00"},
    {"Title":"Bla bla","ID":124,"Date":"26-06-2012 12:50:00"}]}
  • 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-12T20:47:41+00:00Added an answer on June 12, 2026 at 8:47 pm

    Here is your example:

    $(function(){
        var data = [{Title:'title 1', Date: 'date 1', Id: 1},
                    {Title:'title 2', Date: 'date 2', Id: 2},
                    {Title:'title 3', Date: 'date 3', Id: 3}];
    
        $("#list").html($("#items").render(data));
    });
    

    Demo: http://jsfiddle.net/9mBhd/

    You need to check: data and selectors in your code, also note that you will remove template with html() from #list in your example.

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

Sidebar

Related Questions

Trying to get this expression to work, can someone look at it and tell
Trying to get all articles, with unique titles (distinct(title)), that have a body of
I am trying get a div that I have hidden to show in the
I am trying get currently focused component id. For this I used following jQuery:
I am trying get Struts 2 and Tiles to work and I am using
I can't figure this out, I am trying to get the pictures from googles
I'm trying get some licensing code from AndroidPit.com working, but I get Unable to
I am trying get the html within .event_recur. $(.entry).each(function(){ alert($(this).find(.event_recur).html()); }); <div class=entry> <p
I'm trying get cross compiling between 2.7.7 and 2.8.0. The package is included, this
Hello everyone I been trying get php uploader working but having a lot of

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.