티스토리 뷰
Class
public class Paging
{
/// <summary>
/// 현재 페이지 번호
/// </summary>
public int CurrentPageNumber { get; set; }
/// <summary>
/// 총 페이지
/// </summary>
public int TotalPage { get; set; }
/// <summary>
/// 시작 페이지 번호
/// </summary>
public int StartPageNumber { get; set; }
/// <summary>
/// 끝 페이지 번호
/// </summary>
public int EndPageNumber { get; set; }
/// <summary>
/// 페이징 처리를 한다.
/// </summary>
/// <param name="totalRow">총 행의 수</param>
/// <param name="rowSize">한 페이지에 출력할 행의 수</param>
/// <param name="currentPageNumber">현재 페이지 번호</param>
/// <param name="pageBlockSize">페이징수</param>
public Paging(int totalRow, int rowSize, int currentPageNumber, int pageBlockSize)
{
int totalPage = (int)Math.Ceiling((double)totalRow / rowSize);
int currentPageBlock = (int)Math.Ceiling((double)currentPageNumber / pageBlockSize);
int startPageNumber = ((currentPageBlock - 1) * pageBlockSize) + 1;
int endPageNumber = (startPageNumber + pageBlockSize) - 1 <= totalPage ? (startPageNumber + pageBlockSize) - 1 : totalPage;
this.CurrentPageNumber = currentPageNumber;
this.TotalPage = totalPage;
this.StartPageNumber = startPageNumber;
this.EndPageNumber = endPageNumber;
}
}
Controler
ViewData["Paging"] = new Paging(board.TotalRow, rowSize, currentPageNumber.Value, pageBlockSize);
View
<% Html.RenderPartial("StyleOfPageNumber", ViewData["Paging"] as Klattermusen.Entity.Board.Paging); %>
Partial View
<%
string uri = string.Format("/{0}/{1}?"
, ViewContext.Controller.ValueProvider.GetValue("controller").RawValue
, ViewContext.Controller.ValueProvider.GetValue("action").RawValue);
string search = string.Format("&searchType={0}&searchWord={1}"
, HttpContext.Current.Request.QueryString["searchType"]
, HttpContext.Current.Request.QueryString["searchWord"]);
string preLink = Model.CurrentPageNumber > 1 ? uri + "currentPageNumber=" + (Model.CurrentPageNumber - 1) : "javascript:alert('이전 페이지가 존재하지 않습니다.');";
string nextLink = Model.CurrentPageNumber < Model.TotalPage ? uri + "currentPageNumber=" + (Model.CurrentPageNumber + 1) : "javascript:alert('다음 페이지가 존재하지 않습니다.')";
%>
<nav style="text-align:center;">
<ul class="pagination">
<li><a href="<%= preLink %>" aria-label="Previous"><span aria-hidden="true">«</span></a></li>
<% for (int i = Model.StartPageNumber; i <= Model.EndPageNumber; i++) { %>
<% if(Model.CurrentPageNumber == i) { %>
<li><a href="#" style="background-color:#eee;"><strong><%= i %></strong></a></li>
<% } else { %>
<li><a href="<%= uri %>currentPageNumber=<%= i %><%= search %>"><%= i %></a></li>
<% } %>
<% } %>
<li><a href="<%= nextLink %>" aria-label="Next"><span aria-hidden="true">»</span></a></li>
</ul>
</nav>
- Total
- Today
- Yesterday
- java web-mvc
- java-개발 환경 설정하기
- error-java
- docker
- System.Diagnostics
- 문자 자르기
- React
- 메이븐(maven)
- REST API
- jsp 오픈 소스
- MainActor
- await
- 스프링 프레임워크(spring framewordk)
- In App Purchase
- system.io
- 스프링 프레임워크(spring framework)
- 스프링 시큐리티(spring security)
- jstl(java standard tag library)-core
- 스프링 시큐리티(spring security)-http basic 인증
- 람다식(lambda expression)
- 표현 언어(expression language)
- 특정 문자를 기준으로 자르기
- java.sql
- .submit()
- jstl(java standard tag library)
- 진수 변환
- 제품 등록
- java 키워드 정리
- 인텔리제이(intellij)
- nl2br
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |