Paging TagHelper - Ajax >= v4.0

Ajax Sample : Cultures Table

LCID English Name Native Name
4096 Kiswahili (Tanzania) Kiswahili (Tanzania)
4096 Kiswahili (Uganda) Kiswahili (Uganda)
87 Konkani कोंकणी
1111 Konkani (India) कोंकणी (भारत)
18 Korean 한국어
1042 Korean (Korea) 한국어(대한민국)
4096 Korean (North Korea) 한국어 (조선민주주의인민공화국)
4096 Koyra Chiini Koyra ciini
4096 Koyra Chiini (Mali) Koyra ciini (Maali)
4096 Koyraboro Senni Koyraboro senni
4096 Koyraboro Senni (Mali) Koyraboro senni (Maali)
4096 Kurdish (Perso-Arabic, Iran) کوردی (ئێران)
4096 Kwasio Kwasio
4096 Kwasio (Cameroon) Kwasio (Kamerun)
64 Kyrgyz Кыргыз
1088 Kyrgyz (Kyrgyzstan) Кыргыз (Кыргызстан)
4096 Lakota Lakȟólʼiyapi
4096 Lakota (United States) Lakȟólʼiyapi (Mílahaŋska Tȟamákȟočhe)
4096 Langi Kɨlaangi
4096 Langi (Tanzania) Kɨlaangi (Taansanía)
84 Lao ລາວ
1108 Lao (Laos) ລາວ (ລາວ)
118 Latin lingua latīna
1142 Latin (World) lingua latīna (World)
38 Latvian latviešu
1062 Latvian (Latvia) latviešu (Latvija)
4096 Lingala lingála
4096 Lingala (Angola) lingála (Angóla)
4096 Lingala (Central African Republic) lingála (Repibiki ya Afríka ya Káti)
4096 Lingala (Congo DRC) lingála (Republíki ya Kongó Demokratíki)
4096 Lingala (Congo) lingála (Kongo)
39 Lithuanian lietuvių
1063 Lithuanian (Lithuania) lietuvių (Lietuva)
4096 Low German Neddersass’sch
4096 Low German (Germany) Neddersass’sch (Düütschland)
4096 Low German (Netherlands) Neddersass’sch (Nedderlannen)
31790 Lower Sorbian dolnoserbšćina
2094 Lower Sorbian (Germany) dolnoserbšćina (Nimska)
4096 Luba-Katanga Tshiluba
4096 Luba-Katanga (Congo DRC) Tshiluba (Ditunga wa Kongu)
4096 Luo Dholuo
4096 Luo (Kenya) Dholuo (Kenya)
110 Luxembourgish Lëtzebuergesch
1134 Luxembourgish (Luxembourg) Lëtzebuergesch (Lëtzebuerg)
4096 Luyia Luluhia
4096 Luyia (Kenya) Luluhia (Kenya)
47 Macedonian македонски
1071 Macedonian (Macedonia, FYRO) македонски (Република Македонија)
4096 Machame Kimachame
4096 Machame (Tanzania) Kimachame (Tanzania)

Setup for ajax

  • Create a div element that will handle the updated the content
    <div class="items"></div>
  • Create a partial view to render in the target area e.g. PagingItemsPartial.cshtml. The partial view model is the same as the page model in out sample PagingAjaxModel.
  • Put the paging taghelper in the partial, currently it supports only "replace" mode for ajax, thats why we have to keep the paging inside the partial, so it will refresh with the partial data accordingly.
  • Use ajax-... attributes to add ajax support to the PagingTagHelper.
  • In the backend, create the relevant handler that will return the partial view via ajax.
  • Add reference to ajax in the Scripts section:
    <script src="https://cdn.jsdelivr.net/npm/jquery-ajax-unobtrusive@3.2.6/dist/jquery.unobtrusive-ajax.min.js"></script>

Sample partial view with Paging control included

            
@model PagingAjaxModel

<table class="table table-striped">
    <thead>
        <tr>
            <th>LCID</th>
            <th>English Name</th>
            <th>Native Name</th>
        </tr>
    </thead>
    <tbody>
        @if (Model.TotalRecords == 0)
        {
            <tr>
                <td colspan="3">No records!</td>
            </tr>
        }
        else
        {
            foreach (var c in Model.CulturesList)
            {
                <tr>
                    <td>@c.LCID</td>
                    <td>@c.EnglishName</td>
                    <td>@c.NativeName</td>
                </tr>
            }
        }
    </tbody>
    <tfoot>
        <tr>
            <td colspan="3">
                <paging page-no="Model.P"
                        page-size="Model.S"
                        total-records="Model.TotalRecords"
                        ajax="true"
                        ajax-url="?handler=AjaxPaging"
                        ajax-update="#items"
                        ajax-loading="#loading-spinner"></paging>
            </td>
        </tr>
    </tfoot>
</table>