//*******default.aspx********//
//*********Div for pagin*********//
<div style="float: left; width: 672px;" id="lblKBPaging"></div>
//*****Hidden variables used for Paging***************//
<input type="hidden" id="hKBTotalCount" value="0" />
<input type="hidden" id="hKBCurrentPage" value="1" />
<input type="hidden" id="hKBNextPage" value="0" />
<input type="hidden" id="hKBPreviousPage" value="0" />
[**********abc.js**************]
// hKBTotalCount will give us Total Rows return by procedure
function abc(){
$('#hKBTotalCount').val(result.d[0].TotalRows);
$('#lblKBPaging').show();
CallPaging();
}
function RowN(TotalCount) {
var TotalP;
TotalP = (TotalCount / KBShowRecord).toFixed(2);
var chkTotal = TotalP - Math.floor(TotalP);
if (chkTotal != 0) {
TotalP = Math.floor(TotalP) + 1;
}
return TotalP;
}
function GetPage(V, C) {
$('#hKBCurrentPage').val(C);
GetAgentWiseUsage(V);
}
function Page(NextPage, Previous) {
$('#hKBNextPage').val(NextPage);
$('#hKBPreviousPage').val(Previous);
CallPaging();
}
var KBShowRecord = 10;
var PagingBreak;
function CallPaging() {
Paging($('#hKBNextPage').val(), $('#hKBCurrentPage').val(), $('#hKBPreviousPage').val())
}
function Paging(NextP, Current, Previous) {
var NextPageNo, CurrentPage;
var RowCount = RowN($('#hKBTotalCount').val());
if (NextP != 0) {
NextPageNo = NextP;
}
else {
NextPageNo = 0;
}
if (Current != '') {
CurrentPage = Current;
}
else {
CurrentPage = 1;
}
var strB = '';
var final = '';
if (Previous == 1) {
NextPageNo = Math.floor(Number(NextPageNo) - Number(10));
}
PagingBreak = Math.floor(Number(NextPageNo) + Number(10));
if (PagingBreak > 10) {
var iddd = Number(PagingBreak) - Number(10);
strB += '<label id="PageBack' + iddd + '" onclick="Page(' + iddd + ',1)" style="cursor:pointer">....</label>';
strB += '';
}
iLoop:
for (var i = NextPageNo; i < RowCount; i++) {
var txt, vcss;
txt = (Number(i) + Number(1));
if (txt == CurrentPage) {
vcss = '#1d94b6';
}
else {
vcss = 'Black';
}
var idd = (Number(i) * Number(KBShowRecord)) + Number(1);
strB += '<label id="PageInner' + idd + '" onclick="GetPage(' + idd + ',document.getElementById(this.id).innerHTML)" style="cursor:pointer; color: ' + vcss + '">' + txt + '</label>';
strB += '';
if (txt == PagingBreak) {
if (PagingBreak == RowCount) {
final = '<div style="float: left; width: 500px; padding-left: 10px; font-family: Helvetica; font-size: 13px"><b>Page ' + CurrentPage + ' of ' + RowCount + '</b> ' + strB + '</div>';
break iLoop;
}
strB += '<label id="PageNext' + txt + '" onclick="Page(' + txt + ',0)" style="cursor:pointer; color: ' + vcss + '">....</label>';
final = '<div style="float: left; width: 500px; padding-left: 10px; font-family: Helvetica; font-size: 13px"><b>Page ' + CurrentPage + ' of ' + RowCount + '</b> ' + strB + '</div>';
break iLoop;
}
final = '<div style="float: left; width: 500px; padding-left: 10px; font-family: Helvetica; font-size: 13px"><b>Page ' + CurrentPage + ' of ' + RowCount + '</b> ' + strB + '</div>';
}
$('#lblKBPaging').html(final);
}