|
![]() | 作者: whf0901 [whf0901]
![]() |
登录 |
个人做网站的一些经验与技巧,欢迎进来讨论 1.几个常用函数 Round(pi, 2) 四舍五入 FormatNumber(k,4) ' 把 k 格式化为带四位小数点的数。 eg. 如果k =20000则显示为20,000.00;如果把formatnumber(k,0)则为20,000 Replace(expression,find,replacewith) '返回一字符串,其中指定的子串已被另一个子串替换 Left(String,Length) '返回指定数目的从字符串的左边算起的字符串。 Split(expression[, delimiter[, count[, start]]]) '返回基于 0 的一维数组,其中包含指定数目的子字符串。 eg. 常用这个 Split(String,[delimiter]) ' 用delimiter(用于标识子字符串界限的字符)来划分字符串 Instr(String1,String2) '返回某字符串在另一字符串中第一次出现的位置 eg1. if instr(addation,"密码配置表")<>0 then '说明存在 eg2. if instr(str,”AP”) >0 不好区分str = (AP,AP&AC),此时只要变为(’AP’,’AP&AC’),再用instr(str,”’AP’”) 2. 弹出窗口Pick值 function pickupSP(spdisid,pjnum,pdcode) { window.opener.<%=theForm%>.RefNum<%=Spid%>.value=spdisid; window.opener.<%=theForm%>.LineS<%=Spid%>.value=pjnum; window.opener.<%=theForm%>.kokey<%=Spid%>.value=pdcode; window.close(); } 3. ASP控制图片显示的大小(等比例缩放) <HTML> <HEAD> <TITLE> New Document </TITLE> <script language="JavaScript"> <!-- var flag=false; function DrawImage(ImgD){ var image=new Image(); image.src=ImgD.src; if(image.width>0 && image.height>0){ flag=true; if(image.width/image.height>= 164/112){ if(image.width>164){ ImgD.width=164; ImgD.height=(image.height*164)/image.width; }else{ ImgD.width=image.width; ImgD.height=image.height; } ImgD.alt=image.width+"x"+image.height; } else{ if(image.height>112){ ImgD.height=112; ImgD.width=(image.width*112)/image.height; }else{ ImgD.width=image.width; ImgD.height=image.height; } ImgD.alt=image.width+"x"+image.height; } } } //--> </script> </HEAD> <BODY> <a href="./img.jpg" target="_blank"><img src="./img.jpg" border="0" width="164" height="112" onload="javascript:DrawImage(this);"></a> </BODY> </HTML> 4. ASP中对数据库表的操作(INSERT/UPDATE/DELETE),可使用事务处理,并支持多事务处理. 在ASP的数据库对象链接对象中,提供了一下属性: BeginTrans 事务开始 CommitTrans 事务提交 RollbackTrans 事务回滚 <% On Error Resume Next ’错误发生后继续处理 'Asp中使用事务 Set conn=Server.CreateObject("ADODB.Connection") conn.Open "course_dsn","course_user","course_password" conn.begintrans '开始事务 sql="delete from user_info" set rs=server.createobject("adodb.recordset") rs.open sql,conn,3,3 if conn.errors.count>0 then '有错误发生 conn.rollbacktrans '回滚 set rs=nothing conn.close set conn=nothing response.write "交易失败,回滚至修改前的状态!" response.end else conn.committrans '提交事务 set rs=nothing conn.close set conn=nothing response.write "交易成功!" response.end end if %> 在ASP中,不提供事务的结束,BeginTrans只作用于自己的域,类似于变量声明一样,如果在函数体内BeginTrans,则事物只作用于本函数体,如果BeginTrans在函数体外,处于页面级,则事务的作用域从BeginTrans开始,到页面的结束均处于事务的管理状态下. 介绍一款支持ASP的虚拟主机给你们!我用的是时代互联商务C型1650元/年,高速稳定,大家可申请试试,支持域名DNS轮循,还送繁简通,加速器!拥有ICP、ISP、红盾首级网络服务提供商时代互联搞促销活动,商务C型原价1650年/年,现价只需1580元/年,还多送一个域名呢!真是一个难得的好机会呀! http://www.now.net.cn/vhost/ |
地主 发表时间: 06-03-07 09:31 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号