NETEU 发表于 2006-5-3 22:17:56

菜鸟提高 ASP开发技巧集锦二

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