3초기억력

asp - paging 함수 본문

플밍_ASP

asp - paging 함수

잠수콩 2010. 3. 24. 12:35



 Function GetPageList(ByVal CurPage, ByVal PageCount, ByVal PageScale, ByVal Parametter, ByVal DesignType)
  Dim Path, PrevPage, NextPage, LastPage, FirstPage, PageStr
  Dim FirstImg, NextImg, LastImg, PrevImg
  Dim FromPage, ToPage, i

  Select Case DesignType
  
   Case "Text"
    FirstImg = "◀◀"
    PrevImg = "◀"
    NextImg = "▶"
    LastImg = "▶▶"
   
   Case Else
    FirstImg = "<img src='/images/common/pgbtn_pprev.gif' align='absmiddle'>"
    PrevImg = "<img src='/images/common/pgbtn_prev.gif' align='absmiddle'>"
    NextImg = "<img src='/images/common/pgbtn_next.gif' align='absmiddle'>"
    LastImg = "<img src='/images/common/pgbtn_nnext.gif' align='absmiddle'>"
  End Select


  '링크 문자열
  Path = Request.ServerVariables("PATH_INFO") & "?Page="
  FromPage = Int((CurPage - 1) / PageScale) * PageScale + 1
  If PageCount > FromPage + (PageScale - 1) Then
   ToPage = FromPage + (PageScale - 1)
  Else
   ToPage = PageCount
  End If

  '첫페이지
  FirstPage = "<a href='" & Path & "1" & Parametter & "'>" _
   & FirstImg & "</a>"

  ' 이전 10개 표시
  If Int((CurPage - 1) / PageScale) > 0 Then
   PrevPage = "<a href='" & Path & (FromPage - 1) & Parametter & "'>" _
   & PrevImg & "</a>"
  Else
   PrevPage = PrevImg
  End If

  '페이지 네비게이션 표시
  For i = FromPage To ToPage
   If i = Int(CurPage) Then
    PageStr = PageStr & " <b>" & i & "</b> "
   Else
    PageStr = PageStr & " <a href='" & Path & i & Parametter & "'>" & i & "</a> "
   End If
  Next

  '다음 10개 표시
  If ToPage < PageCount Then
   NextPage = "<a href='" & Path & (ToPage + 1) & Parametter & "'>" _
    & NextImg & "</a>"
  Else
   NextPage = NextImg
  End If

  '마지막 페이지   
  LastPage = "<a href='" & Path & PageCount & Parametter & "'>" _
    & LastImg & "</a>"
    
  GetPageList = FirstPage & " " & PrevPage & " " & PageStr & " " & NextPage & " " & LastPage
 End Function

Comments