ASP無組件分頁實現思路及代碼_ASP教程
推薦:ASP如何獲取真實IP地址在 ASP 中使用 Request.ServerVariables(REMOTE_ADDR) 來取得客戶端的 IP 地址,但如果客戶端是使用代理服務器來訪問,那取到的就是代理服務器的 IP 地址,而不是真正的客戶端 IP 地址。要想透過代理服務器取得客戶端的真實IP 地址,就要使用Request.ServerVariables(H
MVC下:后臺代碼:
復制代碼 代碼如下:www.wf0088.com
public ActionResult sys(string page)
{
if (page == null)
{
string sql = "select top 15 * from dingdinfo ORDER BY dingdh desc";
ViewData["ds"] = dr.resultSet(sql, "dingdinfo");
}
if (page != null)
{
int pageSL = Convert.ToInt32(page);
string sql = "select top 15 * from dingdinfo where id not in (select top " + (pageSL - 1) * 15 + " id from dingdinfo order by dingdh desc )ORDER BY dingdh desc";
ViewData["ds"] = dr.resultSet(sql, "dingdinfo");
}
//計算pageCount
string sql1 = "select * from dingdinfo";
int pageCount = dr.resultCount(sql1,"dingdinfo");
int Chu = Convert.ToInt32(pageCount / 15);
int yuS = Convert.ToInt32(pageCount % 15);
if (pageCount > 15)
{
int pageJG = Chu;
if (yuS != 0)
{
pageJG = Chu + 1;
ViewData["jg"] = pageJG;
}
else
{
ViewData["jg"] = pageJG;
}
}
return View();
}
頁面顯示:
JS代碼:
復制代碼 代碼如下:www.wf0088.com
<script type="text/javascript">
//分頁
function Page(id) {
window.location = "/bookIndex/sys/?page=" + id;
}
</script>
HTML代碼:
復制代碼 代碼如下:www.wf0088.com
<td>
<% int count =Convert.ToInt32(ViewData["jg"]);
if (count != 0)
{
for (int i = 1; i <=count; i++)
{ %>
<a href = "#" onclick="Page(<%:i%>)"><%:i%></a>
<% }
}%>
</td>
頁面最終效果:
分享:asp之FSO大全對于一個支持asp和fso的空間來說有了fso一切變得簡單多了 我也是個新手寫了一些代碼供大家學習研究用 首先看支持fso組件嗎 % 'FSO組件名稱 dim FSObject FSObject=Scripting.FileSystemObject '========================================================= '◆是否支持
相關ASP教程:
- 相關鏈接:
- 教程說明:
ASP教程-ASP無組件分頁實現思路及代碼。