How to realize paging navigation with ASP.Net
This article mainly shows you "ASP.Net how to achieve paging navigation", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to achieve paging navigation in ASP.Net" this article.
Asp.Net paging can set the link text displayed in the foreground of the first page, the previous page, the next page, and the last page of the page. Here only mention the simple function, in-depth study and analysis of its principle is more handy.
/ / the target container for containerId navigation. It is recommended to use the span tag / / url default to XXX.XX?pagenum= / / curPage current page number / / maxSection maximum number of segments (maximum number of pages in a paragraph) / / totalPage total number of pages function Navigate (containerId,url,curPage,maxSection, totalPage) {/ / to the first page symbol var first = "| |; / / previous page symbol var back =" / / illegal page number processing if (curPage > totalPage | | curPage
< 0) { curPage = 1; } //获得导航容器父元素 var containerObj = document.getElementById(containerId); //获得当前页所在的分段号(调试了老半天原来是类型问题,居然是float型) var curSection = Math.floor((curPage - 1) / maxSection + 1); //获得最后一个分段的号 var lastSection = Math.floor((totalPage - 1) / maxSection + 1); var html = ""; //当前页不是第1页,添加到首页,和前一页 if (curPage >1) {html + = "...";} / the first page number of the current segment var curSectionFirst = (curSection-1) * maxSection + 1; / / the last page number of the current segment var curSecitonLast = curSection * maxSection; / / outputs the page number of the current segment for (var I = curSectionFirst; I