菜鸟提高 ASP开发技巧集锦二
发表于:2007-09-07来源:作者:点击数:
标签:
11. 报错并返回 if rs.bof and rs.eof then ‘还是有问题 response.write"SCRIPT language= Java Scriptalert('找不到!');" response.write" java script:history.go(-1)/SCRIPT" end if --------------------------------
11. 报错并返回
if rs.bof and rs.eof then ‘还是有问题
response.write"<SCRIPT language=
JavaScript>alert('找不到!');"
response.write"
javascript:history.go(-1)</SCRIPT>"
end if
-----------------------------------
这个是跳转。
<script language="javascript">
alert('<%=intOperationInfo%>');
window.navigate('ChangePwd.asp');
</Script>
12. 从
VBS到JS,混用
<%
dim checkpwdconfig
checkpwdconfig=split(addation,"/")
%>
<script language="javascript">
alert("<%=checkpwdconfig(0)%>")
</script>
13. 弹出窗口
<script language=javascript>
function openaddnew()
{
subWindow=window.open("../Edit/PasswordConfigEdit.asp?method=new",'','scrollbars=yes,left=120,top=60,height=250,width=500,
menubar=no,location=no,toolbar=no,resizable=yes','')
subWindow.opener = this;
}
</script>
用一个连接调用:
<a href=""#"">请修改密码 onClick="openaddnew()"</a>
图片调用:
<img name=submit1 src="../button_new<%=session("languageid")%>.gif" onClick="openaddnew()">
14. 分页
<!--#include file="conn.asp"-->
<%
if request("pageno")<>"" then
pageno=int(request("pageno"))
else
pageno=1
end if
sql="select * from news where [language]='中文' and bigclassname='
新闻' order by id desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
rs.pagesize=20
if rs.eof then
pageno=0
else
rs.absolutepage=pageno
end if
%>
==========================================
共<%=rs.recordcount%>条,<%=pageno%>/<%=int(rs.pagecount)%>页,每页<%=rs.pagesize%>条
<a href="manage.asp?pageno=1">首页</a>
<%if pageno>1 then%>
<a href="manage.asp?pageno=<%=int(pageno)-1%>">上一页</a>
<%
end if
if int(pageno)<>int(rs.pagecount)then
%>
<a href="manage.asp?pageno=<%=int(pageno+1)%>">下一页</a>
<%end if%>
<a href="manage.asp?pageno=<%=int(rs.pagecount)%>">尾页</a>
<%rs.close%>
<%
call CloseConn()
%>
15.
数据库更新
sql="select * from [user] where username='"&request("username")&"'"
rs.Open sql,Conn,1,3
rs("usermail")=Request("usermail")
rs("userhome")=Request("userhome"))
rs.update
rs.close
16. 关闭独立窗口
<head>
<OBJECT id=closes type="application/x-oleobject" classid="clsid:adb880a6-d8ff- 11cf-9377-00aa003b7a11"><param name="Command" value="Close">
</object>
</head>
<body>
<input type="button" value="点击我关闭窗口" onclick="closes.Click();">
</body>
17. 极细表格
<table border="1" cellpadding="0" cellspacing="0" width="32" height="32" bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr>
<td> </td>
</tr>
</table>
18. 几个正则表达式
Require : /.+/,
Email : /^\w+([-+.]\w+)*@\w+([-.]\\w+)*\.\w+([-.]\w+)*$/,
Phone : /^((\(\d{3}\)) (\d{3}\-))?(\(0\d{2,3}\) 0\d{2,3}-)?[1-9]\d{6,7}$/,
Mobile : /^((\(\d{3}\)) (\d{3}\-))?13\d{9}$/,
Url : /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/,
IdCard : /^\d{15}(\d{2}[A-Za-z0-9])?$/,
Currency : /^\d+(\.\d+)?$/,
Number : /^\d+$/,
Zip : /^[1-9]\d{5}$/,
QQ : /^[1-9]\d{4,8}$/,
Integer : /^[-\+]?\d+$/,
Double : /^[-\+]?\d+(\.\d+)?$/,
English : /^[A-Za-z]+$/,
Chinese : /^[\u0391-\uFFE5]+$/,
UnSafe :/^(([A-Z]* [a-z]* \d* [-_\~!@#\$%\^&\*\.\(\)\[\]\{\}<>\?\\\/\'\"]*) .{0,5})$ \s/,
19. Left应用(控制字数)
function title(str)
if len(trim(str))>=28 then
title=left(trim(str),27)&"..."
else
title=trim(str)
end if
end function
20. 判断浏览器
<SCRIPT LANGUAGE="javascript1.2">
<!--//
if (navigator.appName == 'Netscape')
var language = navigator.language;
else
var language = navigator.browserLanguage;
if (language.indexOf('en') > -1) document.location.href = 'en/index.asp';
else if (language.indexOf('zh') > -1) document.location.href = 'cn/index.asp';
else
document.location.href = 'cn/index.asp';
// End -->
</script>
|
原文转自:http://www.ltesting.net