首页 >>ASP网页设计>>正文
 
制作思想(三)
 

1.客户端向服务器的某个ASP程序发出查询条件。
2.该ASP程序响应,并连接数据库。
3.数据库将查询结果返回给该ASP程序。
4.获得数据后,用ASP程序将数据格式化为XML格式,
从而将查询结果建立为该ASP的内嵌式XML对象。
5.在客户端实现XML的分页(分页方法类似于数据库分页)
6.此后,无论是客户端将查询结果翻多少页看多少遍,均不会再与服务器发生交互。
另外,就算是客户端断开网线,也仍然可以浏览还未浏览的分页页面。
下面是我写的一个歌曲在线播放程序页面程序,由两个文件构成:
songList.mdb 一个数据库,装载着歌曲信息。
songList.asp ASP程序,数据库中的数据格式成XML,页面完全显示后,无论点多少次
“下一首”,也不会与服务器交互。
◆songList.asp◆
点击后面的链接查看实例 查看
===========================================================================
<html>
<head>
<title>殷亮的在线播放</title>
<style type="text/css">
<!--
.input
{
background-color: #000000;
border: #000000;
color: #FF9900;
}
-->
</style>
</head>
<body bgcolor="#000000" text="#FF9900">
<% ''''''''''''''''''''''''''''''''''''''''连接数据库''''''''''''''''''''''''''''''''''''''''''''''''''
set songCon = Server.CreateObject("ADODB.connection")
conPath = Server.MapPath("songList.mdb")
conStr = "DRIVER={Microsoft Access Driver (*.mdb)}; dbq="
songCon.open(conStr & conPath)
set rs = Server.CreateObject("ADODB.Recordset")
rs.open "Select * from songList",songCon,3,3
%>
<!--动态生成内嵌式XML文档,"在线播放"是根标记-->
<xml id = "xmlFile">
<在线播放>
<%
If not rs.eof then
while not rs.eof
%>
<歌曲>
<歌名><%= trim(rs("song_name")) %></歌名>
<URL><%= trim(rs("song_url")) %></URL>
<演唱者><%= trim(rs("songer")) %></演唱者>
<歌词><%= trim(rs("song_lyrics")) %></歌词>
</歌曲>
<%
rs.movenext
wend
End If
%>
</在线播放>
</xml>
<div id="Layer1" style="position:absolute; width:500px; height:59px; z-index:1; left: 118px; top: 4px;">
<!--Window Media Player控件-->
<OBJECT classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="500" height="43" id="player" style="WIDTH: 500px; HEIGHT: 43px" VIEWASTEXT>
<PARAM NAME="AudioStream" value="-1">
<PARAM NAME="AutoSize" value="0">
<PARAM NAME="AutoStart" value="-1">
<PARAM NAME="AnimationAtStart" value="-1">
<PARAM NAME="AllowScan" value="-1">
<PARAM NAME="AllowChangeDisplaySize" value="-1">
<PARAM NAME="AutoRewind" value="0">
<PARAM NAME="Balance" value="0">
<PARAM NAME="BaseURL" value="">
<PARAM NAME="BufferingTime" value="5">
<PARAM NAME="CaptioningID" value="">
<PARAM NAME="ClickToPlay" value="-1">
<PARAM NAME="CursorType" value="0">
<PARAM NAME="CurrentPosition" value="-1">
<PARAM NAME="CurrentMarker" value="0">
<PARAM NAME="DefaultFrame" value="">
<PARAM NAME="DisplayBackColor" value="0">
<PARAM NAME="DisplayForeColor" value="16777215">
<PARAM NAME="DisplayMode" value="0">
<PARAM NAME="DisplaySize" value="4">
<PARAM NAME="Enabled" value="-1">
<PARAM NAME="EnableContextMenu" value="-1">
<PARAM NAME="EnablePositionControls" value="-1">
<PARAM NAME="EnableFullScreenControls" value="0">
<PARAM NAME="EnableTracker" value="-1">
<PARAM NAME="Filename" value="">
<PARAM NAME="InvokeURLs" value="-1">
<PARAM NAME="Language" value="-1">
<PARAM NAME="Mute" value="0">
<PARAM NAME="PlayCount" value="1">
<PARAM NAME="PreviewMode" value="0">
<PARAM NAME="Rate" value="1">
<PARAM NAME="SAMILang" value="">
<PARAM NAME="SAMIstyle" value="">
<PARAM NAME="SAMIFileName" value="">
<PARAM NAME="SelectionStart" value="-1">
<PARAM NAME="SelectionEnd" value="-1">
<PARAM NAME="SendOpenStateChangeEvents" value="-1">
<PARAM NAME="SendWarningEvents" value="-1">
<PARAM NAME="SendErrorEvents" value="-1">
<PARAM NAME="SendKeyboardEvents" value="0">
<PARAM NAME="SendMouseClickEvents" value="0">
<PARAM NAME="SendMouseMoveEvents" value="0">
<PARAM NAME="SendPlayStateChangeEvents" value="-1">
<PARAM NAME="ShowCaptioning" value="0">
<PARAM NAME="ShowControls" value="-1">
<PARAM NAME="ShowAudioControls" value="-1">
<PARAM NAME="ShowDisplay" value="0">
<PARAM NAME="ShowGotoBar" value="0">
<PARAM NAME="ShowPositionControls" value="-1">
<PARAM NAME="ShowStatusBar" value="0">
<PARAM NAME="ShowTracker" value="-1">
<PARAM NAME="TransparentAtStart" value="0">
<PARAM NAME="VideoBorderWidth" value="0">
<PARAM NAME="VideoBorderColor" value="0">
<PARAM NAME="VideoBorder3D" value="0">
<PARAM NAME="Volume" value="0">
<PARAM NAME="WindowlessVideo" value="0">
</OBJECT>
</div>
<div id="Layer3" style="position:absolute; width:200px; height:115px; z-index:3; left: 120px; top: 140px;"><img src="P_online.jpg" width="300" height="170"></div>
<div id="Layer4" style="position:absolute; width:191px; height:54px; z-index:4; left: 430px; top: 199px;">
<table width="190" height="52" border="1" align="right" bordercolor="#000000" bgcolor="#FF9900">
<tr>
<td height="23" valign="bottom">
<div align="center"></div>
<div align="right">
<input name="btnPre" type="button" disabled="true" id="btnPre" value="上一首">
</div></td>
</tr>
<tr>
<td valign="top">
<div align="right">
<input name="btnNext" type="button" id="btnNext" value="下一首">
</div></td>
</tr>
</table>
</div>
<div id="Layer2" style="position:absolute; width:503px; height:58px; z-index:2; left: 120px; top: 67px;">
<table width="501" border="1">
<tr>
<td width="100"><font color="#FFFFFF" size="2">播放内置歌曲:</font></td>
<td width="317">
<SELECT name="list" size="1" id="list" style="WIDTH: 328px; BACKGROUND-COLOR: darkorange">
<!--用循环来初始化下拉列表-->
<script language="VBScript">
set xml=xmlFile.recordset
xml.MoveFirst
dim num
for num=0 to xml.RecordCount-1
document.write("<OPTION value="&xml("url")&">"&xml("歌名")&"</OPTION>")
xml.MoveNext
next
xml.MoveFirst
</script>
</SELECT>
</td>
<td width="62"><div align="right">
<input name="btnLAN" type="button" id="btnLAN" value="播放">
</div></td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" >播放网络歌曲:</font></td>
<td><input name="textURL" type="text" id="textURL" style="WIDTH: 328px; BACKGROUND-COLOR: darkorange;color: #000000;"></td>
<td><div align="right">
<input name="btnNET" type="reset" id="btnNET" value="播放">
</div></td>
</tr>
</table>
</div>
<div id="Layer5" style="position:absolute; width:500px; height:20px; z-index:5; left: 120px; top: 320px;">
<p><font color="#FFFFFF" size="2">正在播放:
<input name="textSonger" type="text" class="input" id="textSonger" size="15">
演唱的
<input name="textSongName" type="text" class="input" id="textSongName" size="35">
</font></p>
</div>
<div id="Layer6" style="position:absolute; width:500px; height:150px;
z-index:6; left: 120px; top: 349px;">
<textarea name="area" cols="68" rows="15" id="area"
style="BORDER-RIGHT: white double; BORDER-TOP: white double;
BORDER-LEFT: white double;COLOR: #000000; DIRECTION: ltr;
BORDER-BOTTOM: white double;BACKGROUND-COLOR: darkorange;
TEXT-ALIGN: left">
</textarea>
</div>
<!--各按钮的单击事件-->
<script language="VBScript">
sub play()
textSonger.value=xml("演唱者")
textSongName.value=xml("歌名")
textURL.value=""
area.value=xml("歌词")
player.filename=xml("URL")
if xml.AbsolutePosition=xml.recordcount then
btnNext.disabled=true
else
btnNext.disabled=false
end if
if xml.AbsolutePosition=1 then
btnPre.disabled=true
else
btnPre.disabled=false
end if
end sub
sub btnLAN_onclick
xml.MoveFirst
while xml("URL")<>list.value
xml.MoveNext
wend
call play()
end sub
sub btnNET_onclick
player.filename = textURL.value
textSonger.value = ""
textSongName.value = ""
area.value = "自定义网络歌曲"
end sub
sub btnPre_onclick
xml.MovePrevious
list.selectedIndex = list.selectedIndex - 1
call play()
end sub
sub btnNext_onclick
xml.MoveNext
list.selectedIndex = list.selectedIndex + 1
call play()
end sub
</script>
</body>
</html>
===========================================================================
现在,你知道怎么给服务器减负了吗?^-^
一個簡單的驗証碼
网站上有很多登陸都用到了驗証碼,看著好玩自己也寫了個簡單了(好點的就要把驗証碼寫到圖片上去了,有點難度,還沒研究過)先搞個簡單的.
Sub page_load(sender as object,e as eventargs)
If not ispostback then
Dim ranNum As random=New random
''將生成的隨机數寫到label中
lblRanNum.text=ranNum.Next(1111,9999).tostring
end if
end sub
sub BtnOk_Click(sender as object,e as eventargs)
Dim strTemp As string=lblRanNum.text.tostring
''檢查在textbox中輸入的數字和產生的驗証碼是否一致,一致就ok,否則就error
If strTemp=Trim(txtNumber.text) Then
lblMessage.text=”OK!”
lblRanNum.text=ranNum.next(1111,9999).tostring ''如果不寫這句,則產生的驗証碼就一直是葉面第一次加載時生成的驗証碼
else
lblMessage.text=”Error!”
lblRanNum.text=ranNum.next(1111,9999).tostring
end if
end sub
<html>
<body>
<form runat=”server”>
<asp:textbox id=”txtNumber” runat=”server”></asp:textbox>
<asp:button id=”BtnOk” runat=”server” text=”OK”></asp:button>
<asp:label id=”lblRanNum” runat=”server”></asp:label>
<asp:label id=”lblMessage” runat=”server”></asp:label>
</form>
</body>
</html>
''title换行
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>title换行-www.51windows.Net</title>
</head>
<body>
<a href=# title="第一行
第二行
第三行">title分行测试</a>
<a href=# title="第一行第二行第三行">title分行测试</a>
</body>
</html>
<div style="position: absolute; top: 10; right: 10; width: 148; height: 18;cursor:hand">
<input type="button" name="Button" value="查看源代码" onClick= ''window.location = "view-source:" + window.location.href''></div>
 

 

  供稿:admin    
  发表日期:2005-6-4 10:38:41
 -- 本网站由蓝鸟工作室制作维护 --