⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 note3.aspx

📁 几个不错的ASP.NTE例子
💻 ASPX
字号:
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Data.SQL" %>
<HTML><HEAD>
<script runat="server" language="VB">
dim sqlRead as SQLDataReader
dim intStart as integer
dim intLen as integer
dim intPageCount as integer
dim intRecCount as integer
Sub Page_Load(Src As Object, E As EventArgs) 
Dim conn As SQLConnection
Dim Cfg as HashTable
Dim sqlcmd As SQLCommand

Cfg = Context.GetConfig("appsettings")
Conn = New SQLConnection(cfg("Conn"))

dim strSQL as string
'实在是没有办法,只好这样来获得 记录总数了
'根据NGWS的帮助上看 似乎有个PagedDataSource 好象功能挺强大
'但是 就是 不知道 应该怎么使用 也没有见过 用他的例子
strSQL="select count(*) as ccount from msgBoard"
sqlcmd = New SQLCommand(strSQL,conn)
sqlcmd.ActiveConnection.Open()
sqlcmd.execute(sqlRead)
sqlRead.Read()
intRecCount=cInt(sqlRead("ccount"))
sqlcmd.ActiveConnection.Close()
strSQL="select * from msgBoard order by msgid desc"
sqlcmd = New SQLCommand(strSQL,conn)
sqlcmd.ActiveConnection.Open()
sqlcmd.execute(sqlRead)


if isNumeric(request.querystring("start")) then
intStart=Cint(request.querystring("start")) '本页数据起使位置
else
intStart=0 
end if

intLen=10 '每页需要显示的数据数量
'以下计算 当前的 记录的分页页数
if (intRecCount mod intLen)=0 then
intPageCount=intRecCount/intLen
else
intPageCount=(intRecCount-(intRecCount mod intLen))/intLen+1
end if
dim i as integer
'将得到的sqlRead向后移动 start 指定的 位置
for i=0 to intStart-1
sqlRead.read()
next
end sub
sub WritePage(start as integer,file as string)
'进行分页处理
dim strWrite as string
strWrite="<table border=1 width=100%><tr><td>"
response.write(strWrite)

if start=0 then
strWrite="首页"
else
strWrite="<a href='" & file & "?start=0'>首页</a>"
end if
response.write(strWrite)

if start>=1 then
strWrite="<a href='" & file & "?start=" & cStr(start-intLen) & "'>上页</a>"
else
strWrite="上页"
end if
response.write(strWrite)

if start+intLen<intRecCount then
'还没有到最后一页数据
strWrite="<a href='" & file & "?start=" & cStr(start+intLen) & "'>下页</a>"
else
strWrite="下页"
end if
response.write(strWrite)

if start+intLen<intRecCount then
'还没有到最后一页数据
strWrite="<a href='" & file & "?start=" & cStr((intPageCount-1)*intLen) & "'>末页</a>"
else
strWrite="末页"
end if
response.write(strWrite & "</td><td>")

strWrite="当前共有留言" & Cstr(intRecCount) & ",现在是第<font color=red>" & cStr((intStart/intLen)+1) & "/" & cstr(intPageCount) & "</font>页"
response.write(strWrite)
strWrite="</td></tr></table>"
response.write(strWrite)
end sub
</script>
<title>豆腐技术站__aspx分站__查看留言</title>
<link rel="stylesheet" type="text/css" href="/doufu.css">
</HEAD>
<BODY>
<a href="http://www.asp888.net">豆腐技术站</a>亲情奉献<br>
<%
WritePage(intStart,"a.aspx")
dim atEnd as boolean
%>
<% for i=0 to intLen-1%>
<%
atEnd=sqlRead.read()
if not atEnd then exit for
%>
<div align=center>
<table border=1 width=80%>
<tr>
<td width=10%>呢称</td>
<td width=40%><%=sqlRead("nickname")%></td>
<td width=10%>IP地址</td>
<td width=10%><%=sqlRead("IPAddr")%></td>
</tr>
<tr>
<td width=10%>联系方式</td>
<td width=90% colspan=3><%=sqlRead("email")%></td>
</tr>
<tr>
<td width=10%>留言主题</td>
<td width=90% colspan=3><%=sqlRead("msgTitle")%>----<font color=red><%=sqlRead("msgTime")%></font></td>
</tr>
<tr>
<td width=10%>留言内容</td>
<td width=90% colspan=3><%=server.HTMLEncode(sqlRead("msgContent"))%></td>
</tr>
</table>
</div>
<p></p>
<%next%>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -