<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="css/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>文心春萌 - asp</title><link>http://blog.cnxcn.net/</link><description>文心春萌 - </description><generator>RainbowSoft Studio Z-Blog 1.8 Walle Build 91204</generator><language>zh-CN</language><copyright>Copyright Blog.cnxcn.net . All Rights Reserved.</copyright><pubDate>Thu, 09 Sep 2010 20:45:22 +0800</pubDate><item><title>单篇文章自动分页函数</title><author>peijialai@qingdaotse.com (文心春萌)</author><link>http://blog.cnxcn.net/post/196.html</link><pubDate>Tue, 19 Jun 2007 08:37:27 +0800</pubDate><guid>http://blog.cnxcn.net/post/196.html</guid><description><![CDATA[自动分页<br /><div class="HtmlCode">Function AutoSplitPages(StrNewsContent)<br />Dim Inti,StrTrueContent,iPageLen,DLocation,XLocation,FoundStr<!--DVNEWS_AD_BEGIN--><a title="25175你我一起舞官方网站" href="http://www.25175.com/">你我一起舞</a>共续ASP经典辉煌！--POWERED BY 25175<!--DVNEWS_AD_END--><br />&nbsp;If StrNewsContent&lt;&gt;&quot;&quot; and AutoPagesNum&lt;&gt;0 and instr(1,StrNewsContent,&quot;$Page_Split_page$&quot;)=0 then<br />&nbsp;&nbsp;Inti=instr(1,StrNewsContent,&quot;&lt;&quot;)<br />&nbsp;&nbsp;If inti&gt;=1 then '新闻中存在Html标记<br />&nbsp;&nbsp;&nbsp;StrTrueContent=left(StrNewsContent,Inti-1)<br />&nbsp;&nbsp;&nbsp;iPageLen=IStrLen(StrTrueContent)<br />&nbsp;&nbsp;&nbsp;inti=inti+1<br />&nbsp;&nbsp;Else&nbsp;&nbsp;&nbsp;'新闻中不存在Html标记，对内容直接分页即可<br />&nbsp;&nbsp;&nbsp;dim i,c,t<br />&nbsp;&nbsp;&nbsp;do while i&lt; len(StrNewsContent)<br />&nbsp;&nbsp;&nbsp;i=i+1<br />&nbsp;&nbsp;&nbsp;&nbsp;c=Abs(Asc(Mid(StrNewsContent,i,1)))<br />&nbsp;&nbsp;&nbsp;&nbsp;if c&gt;255 then&nbsp;'判断为汉字则为两个字符，英文为一个字符<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t=t+2<br />&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t=t+1<br />&nbsp;&nbsp;&nbsp;&nbsp;end if<br />&nbsp;&nbsp;&nbsp;&nbsp;if t&gt;=AutoPagesNum then&nbsp;&nbsp;'如果字数达到了分页的数量则插入分页符号<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StrNewsContent=left(StrNewsContent,i)&amp;&quot;$Page_Split_page$&quot;&amp;mid(StrNewsContent,i+1)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i=i+6<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t=0<br />&nbsp;&nbsp;&nbsp;&nbsp;end if<br />&nbsp;&nbsp;&nbsp;loop<br />&nbsp;&nbsp;&nbsp;AutoSplitPages=StrNewsContent&nbsp;'返回插入分页符号的内容<br />&nbsp;&nbsp;&nbsp;Exit Function<br />&nbsp;&nbsp;End If<br />&nbsp;&nbsp;iPageLen=0</div><div class="HtmlCode">新闻中存在Html标记时，则用下面的语句来处理<br />&nbsp;&nbsp;<div class="HtmlCode">do while instr(Inti,StrNewsContent,&quot;&gt;&quot;)&lt;&gt;0<br />&nbsp;&nbsp;&nbsp;DLocation=instr(Inti,StrNewsContent,&quot;&gt;&quot;)&nbsp;&nbsp;'只计算Html标记之外的字符数量<br />&nbsp;&nbsp;&nbsp;XLocation=instr(DLocation,StrNewsContent,&quot;&lt;&quot;)<br />&nbsp;&nbsp;&nbsp;If XLocation&gt;DLocation+1 then<br />&nbsp;&nbsp;&nbsp;&nbsp;Inti=XLocation<br />&nbsp;&nbsp;&nbsp;&nbsp;StrTrueContent=mid(StrNewsContent,DLocation+1,XLocation-DLocation-1)<br />&nbsp;&nbsp;&nbsp;&nbsp;iPageLen=iPageLen+IStrLen(StrTrueContent)&nbsp;'统计Html之外的字符的数量<br />&nbsp;&nbsp;&nbsp;&nbsp;If iPageLen&gt;AutoPagesNum then&nbsp;&nbsp;&nbsp;&nbsp;'如果达到了分页的数量则插入分页字符<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FoundStr=Lcase(left(StrNewsContent,XLocation-1))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If AllowSplitPages(FoundStr,&quot;table|a|b&gt;|i&gt;|strong|div&quot;)=true then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StrNewsContent=left(StrNewsContent,XLocation-1)&amp;&quot;$Page_Split_page$&quot;&amp;mid(StrNewsContent,XLocation)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iPageLen=0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'重新统计Html之外的字符<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br />&nbsp;&nbsp;&nbsp;&nbsp;End If<br />&nbsp;&nbsp;&nbsp;ElseIf XLocation=0 then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'在后面再也找不到&lt;，即后面没有Html标记了<br />&nbsp;&nbsp;&nbsp;&nbsp;Exit Do<br />&nbsp;&nbsp;&nbsp;ElseIf XLocation=DLocation+1 then&nbsp;&nbsp;&nbsp;&nbsp;'找到的Html标记之间的内容为空，则继续向后找<br />&nbsp;&nbsp;&nbsp;&nbsp;Inti=XLocation<br />&nbsp;&nbsp;&nbsp;End If<br />&nbsp;&nbsp;loop<br />&nbsp;End If<br />AutoSplitPages=StrNewsContent<br />End Function</div></div>]]></description><category>asp</category><comments>http://blog.cnxcn.net/post/196.html#comment</comments><wfw:comment>http://blog.cnxcn.net/</wfw:comment><wfw:commentRss>http://blog.cnxcn.net/feed.asp?cmt=196</wfw:commentRss><trackback:ping>http://blog.cnxcn.net/cmd.asp?act=tb&amp;id=196&amp;key=f904a71e</trackback:ping></item><item><title>三种分页方式效率的简单测试</title><author>peijialai@qingdaotse.com (文心春萌)</author><link>http://blog.cnxcn.net/post/195.html</link><pubDate>Tue, 19 Jun 2007 08:36:41 +0800</pubDate><guid>http://blog.cnxcn.net/post/195.html</guid><description><![CDATA[<p class="content">建立表：</p><p class="content">&nbsp;</p><div class="ubb_code" twffan="done"><br />CREATE&nbsp;TABLE&nbsp;[TestTable]&nbsp;(<br />&nbsp;[ID]&nbsp;[int]&nbsp;IDENTITY&nbsp;(1,&nbsp;1)&nbsp;NOT&nbsp;NULL&nbsp;,<br />&nbsp;[FirstName]&nbsp;[nvarchar]&nbsp;(100)&nbsp;COLLATE&nbsp;Chinese_PRC_CI_AS&nbsp;NULL&nbsp;,<br />&nbsp;[LastName]&nbsp;[nvarchar]&nbsp;(100)&nbsp;COLLATE&nbsp;Chinese_PRC_CI_AS&nbsp;NULL&nbsp;,<br />&nbsp;[Country]&nbsp;[nvarchar]&nbsp;(50)&nbsp;COLLATE&nbsp;Chinese_PRC_CI_AS&nbsp;NULL&nbsp;,<br />&nbsp;[Note]&nbsp;[nvarchar]&nbsp;(2000)&nbsp;COLLATE&nbsp;Chinese_PRC_CI_AS&nbsp;NULL&nbsp;<br />)&nbsp;ON&nbsp;[PRIMARY]<br />GO<br /></div><div class="content">&nbsp; </div><p class="content">&nbsp;</p><p class="content">插入数据：(100万条)</p><p class="content">&nbsp;</p><div class="ubb_code" twffan="done"><br />SET&nbsp;IDENTITY_INSERT&nbsp;TestTable&nbsp;ON<br />declare&nbsp;@i&nbsp;int<br />set&nbsp;@i=1<br />while&nbsp;@i&lt;=1000000<br />begin<br />&nbsp;&nbsp;&nbsp;&nbsp;insert&nbsp;into&nbsp;TestTable([id],&nbsp;FirstName,&nbsp;LastName,&nbsp;Country,Note)&nbsp;values(@i,&nbsp;'FirstName_XXX','LastName_XXX','Country_XXX','Note_XXX')<br />&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;@i=@i+1<br />end<br />SET&nbsp;IDENTITY_INSERT&nbsp;TestTable&nbsp;OFF<br /></div><p class="content">&nbsp;</p><p class="content">------------------------------------</p><p class="content">分页方案一：(利用Not&nbsp;In和SELECT&nbsp;TOP分页)<br />语句形式：</p><p class="content">&nbsp;</p><div class="ubb_code" twffan="done"><br />SELECT&nbsp;TOP&nbsp;页大小&nbsp;*<br />FROM&nbsp;TestTable<br />WHERE&nbsp;(ID&nbsp;NOT&nbsp;IN<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(SELECT&nbsp;TOP&nbsp;页大小*页数&nbsp;id<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM&nbsp;表<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ORDER&nbsp;BY&nbsp;id))<br />ORDER&nbsp;BY&nbsp;ID<br /></div><p class="content">&nbsp;</p><p class="content">-------------------------------------</p><p class="content">分页方案二：(利用ID大于多少和SELECT&nbsp;TOP分页）</p><p class="content">&nbsp;</p><div class="ubb_code" twffan="done"><br />SELECT&nbsp;TOP&nbsp;页大小&nbsp;*<br />FROM&nbsp;TestTable<br />WHERE&nbsp;(ID&nbsp;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(SELECT&nbsp;MAX(id)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM&nbsp;(SELECT&nbsp;TOP&nbsp;页大小*页数&nbsp;id<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM&nbsp;表<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ORDER&nbsp;BY&nbsp;id)&nbsp;AS&nbsp;T))<br />ORDER&nbsp;BY&nbsp;ID<br /></div><div class="content"><br />分页方案三：(利用SQL的游标存储过程分页) </div><p class="content">&nbsp;</p><p class="content">&nbsp;</p><div class="ubb_code" twffan="done"><br />create&nbsp;&nbsp;procedure&nbsp;XiaoZhengGe<br />@sqlstr&nbsp;nvarchar(4000),&nbsp;--<a title="25175学生成绩管理查询系统" href="http://www.25175.com/">查询</a>字符串<br />@currentpage&nbsp;int,&nbsp;--第N页<br />@pagesize&nbsp;int&nbsp;--每页行数<br />as<br />set&nbsp;nocount&nbsp;on<br />declare&nbsp;@P1&nbsp;int,&nbsp;--P1是游标的id<br />&nbsp;@rowcount&nbsp;int<br />exec&nbsp;sp_cursoropen&nbsp;@P1&nbsp;output,@sqlstr,@scrollopt=1,@ccopt=1,</div><div class="ubb_code" twffan="done">@rowcount=@rowcount&nbsp;output<br />select&nbsp;ceiling(1.0*@rowcount/@pagesize)&nbsp;as&nbsp;总页数--,@rowcount&nbsp;as&nbsp;总行数,@currentpage&nbsp;as&nbsp;当前页&nbsp;<br />set&nbsp;@currentpage=(@currentpage-1)*@pagesize+1<br />exec&nbsp;sp_cursorfetch&nbsp;@P1,16,@currentpage,@pagesize&nbsp;<br />exec&nbsp;sp_cursorclose&nbsp;@P1<br />set&nbsp;nocount&nbsp;off<br /></div><p class="content">&nbsp;</p><p class="content">测试结果：<br />测试均为每页10条，三个数字依次为三种方案出结果需要的时间，单位为秒：<br />第2页：18，10，29<br />第500页：12，8，21<br />第50000页：16，18，22<br />第500000页：24，16，22<br />&nbsp;&nbsp;&nbsp;&nbsp;这次测试的主要目的是对大数据量不同部分的翻页效率的测试。本以为应该是一个线性的结果，结果发现变化很奇怪。多测试几次结果误差在1、2秒之内，估计sql&nbsp;server对于翻页也是根据不同位置有优化的。看了<a title="25175学生成绩管理查询系统" href="http://www.25175.com/">查询</a>分析，主要的花销还是order&nbsp;by，这还是主键的，如果不是主键，或者是字符串，估计更慢。<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;有兴趣的朋友可以继续做做10万条、无索引、字符串内容的各种测试。。。</p>]]></description><category>asp</category><comments>http://blog.cnxcn.net/post/195.html#comment</comments><wfw:comment>http://blog.cnxcn.net/</wfw:comment><wfw:commentRss>http://blog.cnxcn.net/feed.asp?cmt=195</wfw:commentRss><trackback:ping>http://blog.cnxcn.net/cmd.asp?act=tb&amp;id=195&amp;key=2a25678a</trackback:ping></item><item><title>我常用的ASP分页代码</title><author>peijialai@qingdaotse.com (文心春萌)</author><link>http://blog.cnxcn.net/post/191.html</link><pubDate>Wed, 13 Jun 2007 16:07:52 +0800</pubDate><guid>http://blog.cnxcn.net/post/191.html</guid><description><![CDATA[下面是我写文章系统一直使用的分页代码，拿出来和大家一起分享一下，估计很多象我这样的菜鸟都很需要的，我只是简单的注释了一下代码的使用，大家在使用的时候要根据自己的需要来修改。<br /><br /><br />&lt;%<br />'打开数据记录<br />set&nbsp;rs=server.CreateObject(&quot;ADODB.RECORDSET&quot;)<br />sql=&quot;select&nbsp;*&nbsp;from&nbsp;xxxx&nbsp;order&nbsp;by&nbsp;yyyy&nbsp;desc&quot;&nbsp;'xxxx,yyyy根据自己的情况修改<br />rs.open&nbsp;sql,conn,1,1<br />if&nbsp;rs.eof&nbsp;and&nbsp;rs.bof&nbsp;then<br />response.Write(&quot;当前还没有内容...&quot;)<br />else<br />dim&nbsp;currentpage&nbsp;<br />maxperpage=Sitebooknum&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />rs.pagesize=maxperpage&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />currentpage=request.querystring(&quot;pageid&quot;)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />if&nbsp;currentpage=&quot;&quot;&nbsp;then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />currentpage=1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />elseif&nbsp;currentpage&lt;1&nbsp;then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />currentpage=1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />currentpage=clng(currentpage)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />if&nbsp;currentpage&nbsp;&gt;&nbsp;rs.pagecount&nbsp;then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />currentpage=rs.pagecount&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />end&nbsp;if&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />end&nbsp;if&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />if&nbsp;not&nbsp;isnumeric(currentpage)&nbsp;then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />currentpage=1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />end&nbsp;if&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />dim&nbsp;totalput,n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />totalput=rs.recordcount&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />if&nbsp;totalput&nbsp;mod&nbsp;maxperpage=0&nbsp;then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />n=totalput\maxperpage&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />n=totalput\maxperpage+1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />end&nbsp;if&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />if&nbsp;n=0&nbsp;then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />n=1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />end&nbsp;if&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />rs.move(currentpage-1)*maxperpage&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />i=0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />w=1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />do&nbsp;while&nbsp;i&lt;&nbsp;maxperpage&nbsp;and&nbsp;not&nbsp;rs.eof&nbsp;&nbsp;<br />%&gt;<br /><br /><br /><br /><br />&lt;!--这里显示内容--&gt;<br /><br /><br /><br />&lt;%<br />'循环记录<br />i=i+1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />w=w+1<br />rs.movenext<br />loop<br />end&nbsp;if<br />rs.close<br />set&nbsp;rs=nothing<br />%&gt;<br /><br /><br /><br /><br /><br />&lt;!--调用分页代码--&gt;<br />&lt;table&nbsp;width=&quot;100%&quot;&nbsp;border=&quot;0&quot;&nbsp;align=&quot;center&quot;&nbsp;cellpadding=&quot;0&quot;&nbsp;cellspacing=&quot;0&quot;&gt;<br />&lt;tr&gt;&lt;td&nbsp;width=&quot;85%&quot;&nbsp;align=&quot;center&quot;&gt;&nbsp;共有&lt;font&nbsp;color=&quot;#FF0000&quot;&gt;&lt;%=totalput%&gt;&lt;/font&gt;篇&nbsp;每页&lt;%=maxperpage%&gt;篇&nbsp;当前页数：&lt;%=currentpage%&gt;/&lt;%&nbsp;=n%&gt;&nbsp;&lt;%k=currentpage&nbsp;if&nbsp;k&lt;&gt;1&nbsp;then%&gt;<br />&lt;a&nbsp;href=&quot;?pageid=1&quot;&gt;&nbsp;&lt;font&nbsp;face=webdings&nbsp;size=2&gt;9&lt;/font&gt;首&nbsp;页&lt;/a&gt;&nbsp;&lt;a&nbsp;href=&quot;?pageid=&lt;%=k-1%&gt;&quot;&gt;&nbsp;&lt;font&nbsp;face=webdings&nbsp;size=2&gt;7&lt;/font&gt;前&nbsp;页&lt;/a&gt;<br />&lt;%else%&gt;<br />&lt;font&nbsp;face=webdings&nbsp;size=2&gt;9&lt;/font&gt;首&nbsp;页&nbsp;&lt;font&nbsp;face=webdings&nbsp;size=2&gt;7&lt;/font&gt;前&nbsp;页<br />&lt;%end&nbsp;if%&gt;<br />&lt;%if&nbsp;k&lt;&gt;n&nbsp;then%&gt;<br />&lt;a&nbsp;href=&quot;?pageid=&lt;%=k+1%&gt;&quot;&gt;&nbsp;后&nbsp;页&lt;font&nbsp;face=webdings&nbsp;size=2&gt;8&lt;/font&gt;&lt;/a&gt;&nbsp;&lt;a&nbsp;href=&quot;?pageid=&lt;%=n%&gt;&quot;&gt;&nbsp;末&nbsp;页&lt;font&nbsp;face=webdings&nbsp;size=2&gt;:&lt;/font&gt;&lt;/a&gt;<br />&lt;%else%&gt;<br />后&nbsp;页&lt;font&nbsp;face=webdings&nbsp;size=2&gt;8&lt;/font&gt;&nbsp;末&nbsp;页&lt;font&nbsp;face=webdings&nbsp;size=2&gt;:&lt;/font&gt;<br />&lt;%end&nbsp;if%&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&lt;/td&gt;<br />&lt;td&nbsp;width=&quot;15%&quot;&nbsp;align=&quot;center&quot;&gt;&lt;select&nbsp;name=&quot;pageid&quot;&nbsp;onchange=&quot;javascript:location=this.options[this.selectedIndex].value;&quot;&gt;<br />&lt;%<br />for&nbsp;i&nbsp;=&nbsp;1&nbsp;to&nbsp;n<br />if&nbsp;i&nbsp;=&nbsp;currentpage&nbsp;then%&gt;<br />&lt;option&nbsp;value=&quot;?pageid=&lt;%=i%&gt;&quot;&nbsp;selected&gt;第&lt;%=i%&gt;页&lt;/option&gt;<br />&lt;%else%&gt;<br />&lt;option&nbsp;value=&quot;?pageid=&lt;%=i%&gt;&quot;&gt;第&lt;%=i%&gt;页&lt;/option&gt;<br />&lt;%<br />end&nbsp;if<br />next<br />%&gt;<br />&lt;/select&gt;<br />&lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;/table&gt;<br /><br />]]></description><category>asp</category><comments>http://blog.cnxcn.net/post/191.html#comment</comments><wfw:comment>http://blog.cnxcn.net/</wfw:comment><wfw:commentRss>http://blog.cnxcn.net/feed.asp?cmt=191</wfw:commentRss><trackback:ping>http://blog.cnxcn.net/cmd.asp?act=tb&amp;id=191&amp;key=c7cc5e82</trackback:ping></item><item><title>ASP经典代码列举实例</title><author>peijialai@qingdaotse.com (文心春萌)</author><link>http://blog.cnxcn.net/post/190.html</link><pubDate>Wed, 13 Jun 2007 15:52:54 +0800</pubDate><guid>http://blog.cnxcn.net/post/190.html</guid><description><![CDATA[<p><strong>1.如何用Asp判断你的网站的虚拟物理路径</strong><!--DVNEWS_AD_BEGIN--><a title="25175你我一起舞官方网站" href="http://www.25175.com/">你我一起舞</a>共续ASP经典辉煌！--POWERED BY 25175<!--DVNEWS_AD_END--></p><p>答：使用Mappath方法</p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#000080">&lt;</font><font color="#0000ff">p </font><font color="#800000">align</font><font color="#000080">=</font><font color="#0000a0">center</font><font color="#000080">&gt;&lt;</font><font color="#0000ff">font </font><font color="#800000">size</font><font color="#000080">=</font><font color="#0000a0">4 </font><font color="#800000">face</font><font color="#000080">=</font><font color="#0000a0">Arial</font><font color="#000080">&gt;&lt;</font><font color="#0000ff">b</font><font color="#000080">&gt;</font> The Physical path to this virtual website is: <font color="#000080">&lt;</font><font color="#0000ff">/b</font><font color="#000080">&gt;&lt;</font><font color="#0000ff">/font</font><font color="#000080">&gt; &lt;</font><font color="#0000ff">font </font><font color="#800000">color</font><font color="#000080">=</font><font color="#0000a0">#FF0000 </font><font color="#800000">size</font><font color="#000080">=</font><font color="#0000a0">6 </font><font color="#800000">face</font><font color="#000080">=</font><font color="#0000a0">Arial</font><font color="#000080">&gt; </font><font color="#8000ff">&lt;%</font><font color="#000080">= </font>Server<font color="#000080">.</font>MapPath<font color="#000080">()</font><font color="#8000ff">%&gt; </font><font color="#000080">&lt;</font><font color="#0000ff">/font</font><font color="#000080">&gt;&lt;</font><font color="#0000ff">/p</font><font color="#000080">&gt;</font></td>        </tr>    </tbody></table></p><p>&nbsp;</p><p>2<strong>.我如何知道使用者所用的浏览器？<br /></strong><br />答：使用the Request object方法</p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#8000ff">&lt;%<br />            </font>strBrowser <font color="#000080">= </font>Request<font color="#000080">.</font>ServerVariables<font color="#000080">(</font>HTTP_USER_AGENT<font color="#000080">)<br />            </font><font color="#0000ff">If </font>InStr<font color="#000080">(</font>strBrowser<font color="#000080">, </font><font color="#800000">&quot;MSIE&quot;</font><font color="#000080">) &lt;&gt; </font><font color="#800080">0 </font><font color="#0000ff">Then<br />            &nbsp;&nbsp;&nbsp; </font>Response<font color="#000080">.</font>redirect<font color="#000080">(</font><font color="#800000">&quot;ForMSIEOnly.htm&quot;</font><font color="#000080">)<br />            </font><font color="#0000ff">Else<br />            &nbsp;&nbsp;&nbsp; </font>Response<font color="#000080">.</font>redirect<font color="#000080">(</font><font color="#800000">&quot;ForAll.htm&quot;</font><font color="#000080">)<br />            </font><font color="#0000ff">End If<br />            </font><font color="#8000ff">%&gt;</font></td>        </tr>    </tbody></table></p><p>&nbsp;</p><p><strong>3.如何计算每天的平均反复访问人数</strong><br />答：解决方法</p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#8000ff">&lt;%<br />            </font>startdate <font color="#000080">= </font>DateDiff<font color="#000080">(</font>d<font color="#000080">, </font>Now<font color="#000080">, </font><font color="#800080">01 </font><font color="#000080">/ </font><font color="#800080">01 </font><font color="#000080">/ </font><font color="#800080">1990</font><font color="#000080">)<br />            </font><font color="#0000ff">If </font>strdate<font color="#000080">&lt;</font><font color="#800080">0 </font><font color="#0000ff">Then </font>startdate <font color="#000080">= </font>startdate <font color="#000080">* -</font><font color="#800080">1<br />            </font>avgvpd <font color="#000080">= </font>Int<font color="#000080">((</font>usercnt<font color="#000080">) / </font>startdate<font color="#000080">)<br />            </font><font color="#8000ff">%&gt;<br />            </font>显示结果<br />            <font color="#8000ff">&lt;% </font>response<font color="#000080">.</font>write<font color="#000080">(</font>avgvpd<font color="#000080">) </font><font color="#8000ff">%&gt;<br />            </font>that is it.this page have been viewed since November 10,1998</td>        </tr>    </tbody></table></p><p>&nbsp;</p><p><strong>4.如何显示随机图象</strong></p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#8000ff">&lt;%<br />            </font><font color="#0000ff">Dim </font>p<font color="#000080">, </font>ppic<font color="#000080">, </font>dpic<br />            ppic <font color="#000080">= </font><font color="#800080">12<br />            </font><font color="#0000ff">Randomize<br />            </font>p <font color="#000080">= </font>Int<font color="#000080">((</font>ppic <font color="#000080">* </font>Rnd<font color="#000080">) + </font><font color="#800080">1</font><font color="#000080">)<br />            </font>dpic <font color="#000080">= </font>graphix <font color="#000080">/ </font>randompics <font color="#000080">/ &amp;</font>p<font color="#000080">&amp;.</font>gif<br />            <font color="#8000ff">%&gt;<br />            </font>显示<br />            <font color="#000080">&lt;</font><font color="#0000ff">img </font><font color="#800000">src</font><font color="#000080">=</font><font color="#8000ff">&lt;%</font><font color="#000080">=</font>dpic<font color="#8000ff">%&gt;</font><font color="#000080">&gt;</font></td>        </tr>    </tbody></table></p><p>&nbsp;</p><p><strong>5.如何回到先前的页面</strong> <br />答：<br /></p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#000080">&lt;</font><font color="#0000ff">a </font><font color="#800000">href</font><font color="#000080">=</font><font color="#8000ff">&lt;%</font><font color="#000080">=</font>request<font color="#000080">.</font>serverVariables<font color="#000080">(</font>Http_REFERER<font color="#000080">)</font><font color="#8000ff">%&gt;</font><font color="#000080">&gt;</font>preivous page<font color="#000080">&lt;</font><font color="#0000ff">/a</font><font color="#000080">&gt;</font></td>        </tr>    </tbody></table>&nbsp;<br />或用图片如：</p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#000080">&lt;</font><font color="#0000ff">img </font><font color="#800000">src</font><font color="#000080">=</font><font color="#0000a0">arrowback.gif </font><font color="#800000">alt</font><font color="#000080">=</font><font color="#8000ff">&lt;%</font><font color="#000080">=</font>request<font color="#000080">.</font>serverVariables<font color="#000080">(</font>HTTP_REFERER<font color="#000080">)</font><font color="#8000ff">%&gt;</font><font color="#000080">&gt;</font></td>        </tr>    </tbody></table></p><p>&nbsp;</p><p><strong>6.如何确定对方的IP地址</strong> <br />答： </p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#8000ff">&lt;%</font><font color="#000080">=</font>Request<font color="#000080">.</font>serverVariables<font color="#000080">(</font>REMOTE_ADDR<font color="#000080">)</font><font color="#8000ff">%&gt;</font></td>        </tr>    </tbody></table></p><p>&nbsp;</p><p><strong>7.如何链结到一副图片上</strong> <br />答：<br /></p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#8000ff">&lt;%</font>@Languages<font color="#000080">=</font>vbscript <font color="#8000ff">%&gt;<br />            &lt;%<br />            </font>response<font color="#000080">.</font>expires <font color="#000080">= </font><font color="#800080">0<br />            </font>strimagename <font color="#000080">= </font><font color="#800000">&quot;graphix/errors/erroriamge.gif&quot;<br />            </font>response<font color="#000080">.</font>redirect<font color="#000080">(</font>strimagename<font color="#000080">)<br />            </font><font color="#8000ff">%&gt;</font></td>        </tr>    </tbody></table></p><p>&nbsp;</p><p><strong>8.强迫输入密码对话框</strong> <br />答：把这句话放载页面的开头 <br /></p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#8000ff">&lt;%<br />            </font>response<font color="#000080">.</font>status <font color="#000080">= </font><font color="#800080">401 </font><font color="#008000">' Not Authorized<br />            </font>response<font color="#000080">.</font><font color="#0000ff">End<br />            </font><font color="#8000ff">%&gt;</font></td>        </tr>    </tbody></table></p><p>&nbsp;</p><p><strong>9.如何传递变量从一页到另一页</strong> <br />答：用 HIDDEN 类型来传递变量 <br /></p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#000080"><font face="黑体">&lt;<font color="#0000ff">Form </font><font color="#800000">method </font><font color="#000080">= </font><font color="#0000a0">post </font><font color="#800000">action </font><font color="#000080">= </font><font color="#0000a0">&quot;mynextpage.asp&quot;</font></font><font face="黑体" color="#000080">&gt;<br />            </font><font face="黑体"><font color="#8000ff">&lt;%<br />            </font><font color="#0000ff">For Each </font><font color="#000000">Item </font><font color="#0000ff">in </font><font color="#000000">request</font><font color="#000080">.</font></font><font face="黑体" color="#000000">Form<br />            </font><font face="黑体"><font color="#8000ff">%&gt;<br />            </font><font color="#000080">&lt;</font><font color="#0000ff">input </font><font color="#800000">namee</font><font color="#000080">=</font><font color="#8000ff">&lt;%</font><font color="#000080">=</font><font color="#000000">item</font><font color="#8000ff">%&gt; </font><font color="#0000a0">type=HIDDEN </font><font color="#800000">value</font><font color="#000080">=</font><font color="#8000ff">&lt;%</font><font color="#000080">=</font><font color="#000000">server</font><font color="#000080">.</font><font color="#000000">HTMLEncode</font><font color="#000080">(</font><font color="#000000">Request</font><font color="#000080">.</font><font color="#000000">form</font><font color="#000080">(</font><font color="#000000">item</font><font color="#000080">)) </font><font color="#8000ff">%&gt;</font></font><font face="黑体"><font color="#000080">&gt;<br />            </font><font color="#8000ff">&lt;% </font><font color="#0000ff">next </font></font><font face="黑体"><font color="#8000ff">%&gt;<br />            </font><font color="#000080">&lt;</font><font color="#0000ff">/form</font><font color="#000080">&gt;</font></font></font></td>        </tr>    </tbody></table></p><p>&nbsp;</p><p><strong>10.为何我在 asp 程序内使用 msgbox，程序出错说没有权限</strong> <br />答：由于 asp 是服务器运行的，如果可以在服务器显示一个对话框，那么你只好等有人按了确定之后，你的程序才能继续执行，而一般服务器不会有人守着，所以微软不得不禁止这个函数，并胡乱告诉你 (:) 呵呵) 没有权限。但是ASP和客户端脚本结合倒可以显示一个对话框，as follows: <br /></p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#8000ff">&lt;% </font>yourVar<font color="#000080">=</font><font color="#800000">&quot;测试对话框&quot;</font><font color="#8000ff">%&gt;<br />            </font><font color="#000080">&lt;</font><font color="#0000ff">script </font><font color="#800000">language </font><font color="#000080">= </font><font color="#0000a0">'javascript'</font><font color="#000080">&gt;<br />            </font>alert(<font color="#8000ff">&lt;% </font><font color="#000080">= </font>yourvar<font color="#8000ff">%&gt;</font>);<br />            <font color="#000080">&lt;</font><font color="#0000ff">/script</font><font color="#000080">&gt;</font></td>        </tr>    </tbody></table></p><p>&nbsp;</p><p><strong>11.有没有办法保护自己的源代码，不给人看到</strong> <br />答：可以去下载一个微软的Windows script Encoder，它可以对asp的脚本和客户端javascript/vbscript脚本进行加密。。。不过客户端加密后，只有ie5才能执行，服务器端脚本加密后，只有服务器上安装有script engine 5（装一个ie5就有了）才能执行。 </p><p>&nbsp;</p><p><strong>12.怎样才能将 query string 从一个 asp 文件传送到另一个？</strong> <br />答：前者文件加入下句：</p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#8000ff">&lt;%<br />            </font>Response<font color="#000080">.</font>Redirect <font color="#800000">&quot;second.asp?&quot;</font><font color="#000080">&amp;</font>Request<font color="#000080">.</font>ServerVariables<font color="#000080">(</font>QUERY_STRING<font color="#000080">)<br />            </font><font color="#8000ff">%&gt;</font></td>        </tr>    </tbody></table></p><p>&nbsp;</p><p><strong>13.global.asa文件总是不起作用?</strong> <br />答：只有web目录设置为web application, global.asa才有效，并且一个web application的根目录下 global.asa才有效。IIS4可以使用Inter<a title="25175.net分网站" href="http://www.25175.net/">net</a> Service Manager设置application setting 怎样才能使得htm文件如同asp文件一样可以执行脚本代码？ <!--DVNEWS_AD_BEGIN--><a title="25175你我一起舞官方网站" href="http://www.25175.com/">你我一起舞</a>共续ASP经典辉煌！--POWERED BY 25175<!--DVNEWS_AD_END--></p><p>&nbsp;</p><p><strong>14.怎样才能使得htm文件如同asp文件一样可以执行脚本代码？</strong> <br />答：Inter<a title="25175.net分网站" href="http://www.25175.net/">net</a> Sevices Manager -&gt; 选择default web site -&gt;右鼠键-&gt;菜单属性-〉主目录-&gt; 应用程序设置（Application Setting）-&gt; 点击按钮 配置-&gt; app mapping -&gt;点击按钮Add -&gt; executable browse选择 WINNTSYSTEM32I<a title="25175.net分网站" href="http://www.25175.net/">net</a>SRVASP.DLL EXTENSION 输入 htm method exclusions 输入PUT.DELETE 全部确定即可。但是值得注意的是这样对htm也要由asp.dll处理，效率将降低。 </p><p>15.如何注册组件 <br />答：有两种方法。 <br />第一种方法：手工注册 DLL 这种方法从IIs 3.0一直使用到IIs 4.0和其它的Web Server。它需要你在命令行方式下来执行，进入到包含有DLL的目录，并输入：regsvr32 component_name.dll 例如 c: emp egsvr32 AspEmail.dll 它会把dll的特定信息注册入服务器中的注册表中。然后这个组件就可以在服务器上使用了，但是这个方法有一个缺陷。当使用这种方法注册完毕组件后，该组件必须要相应的设置NT的匿名帐号有权限执行这个dll。特别是一些组件需要读取注册表，所以，这个注册组件的方法仅仅是使用在服务器上没有MTS的情况下，要取消注册这个dll，使用：<br /><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3">regsvr32&nbsp;/u&nbsp;aspobject.dll&nbsp;example&nbsp;c:&nbsp;emp&nbsp;egsvr32&nbsp;/u&nbsp;aneiodbc.dll&nbsp;</td>        </tr>    </tbody></table></p><p>第二种方法：使用MTS(Microsoft Transaction Server) MTS是IIS 4新增特色，但是它提供了巨大的改进。MTS允许你指定只有有特权的用户才能够访问组件，大大提高了网站服务器上的安全性设置。在MTS上注册组件的步骤如下： <br />1) 打开IIS<a title="25175学生成绩管理查询系统" href="http://www.25175.com/">管理</a>控制台。 <br />2) 展开transaction server，右键单击pkgs installed然后选择new package。 <br />3) 单击create an empty package。 <br />4) 给该包命名。 <br />5) 指定administrator帐号或则使用interactive（如果服务器经常是使用administrator 登陆的话）。 <br />6) 现在使用右键单击你刚建立的那个包下面展开后的components。选择 new then component。 <br />7) 选择 install new component 。 <br />8) 找到你的.dll文件然后选择next到完成。 <br />要删除这个对象，只要选择它的图标，然后选择delete。 <br />附注：特别要注意第二种方法，它是用来调试自己编写组件的最好方法，而不必每次都需要重新启动机器了。</p><p>&nbsp;</p><p><strong>16. ASP与Access数据库连接：</strong> </p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#8000ff">&lt;%</font>@ language<font color="#000080">=</font>VBscript<font color="#8000ff">%&gt;<br />            &lt;%<br />            </font><font color="#0000ff">Dim </font>conn<font color="#000080">, </font>mdbfile<br />            mdbfile <font color="#000080">= </font>server<font color="#000080">.</font>mappath<font color="#000080">(</font><font color="#800000">&quot;数据库名称.mdb&quot;</font><font color="#000080">)<br />            </font><font color="#0000ff">Set </font>conn <font color="#000080">= </font>server<font color="#000080">.</font>CreateObject<font color="#000080">(</font>adodb<font color="#000080">.</font>connection<font color="#000080">)<br />            </font>conn<font color="#000080">.</font>Open driver <font color="#000080">= {</font>microsoft access driver <font color="#000080">(*.</font>mdb<font color="#000080">)};</font>uid <font color="#000080">= </font>admin<font color="#000080">;</font>pwd <font color="#000080">= </font>数据库密码<font color="#000080">;</font>dbq <font color="#000080">= &amp;</font>mdbfile<br />            <font color="#8000ff">%&gt;</font></td>        </tr>    </tbody></table></p><p>&nbsp;</p><p>17.<strong> ASP与SQL数据库连接：</strong> </p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#8000ff">&lt;%</font>@ language<font color="#000080">=</font>VBscript<font color="#8000ff">%&gt;<br />            &lt;%<br />            </font><font color="#0000ff">Dim </font>conn<br />            <font color="#0000ff">Set </font>conn <font color="#000080">= </font>server<font color="#000080">.</font>CreateObject<font color="#000080">(</font>ADODB<font color="#000080">.</font>connection<font color="#000080">)<br />            </font>con<font color="#000080">.</font>Open PROVIDER <font color="#000080">= </font>SQLOLEDB<font color="#000080">;</font>DATA Source <font color="#000080">= </font>SQL服务器名称或IP地址<font color="#000080">;</font>UID <font color="#000080">= </font>sa<font color="#000080">;</font>PWD <font color="#000080">= </font>数据库密码<font color="#000080">;</font>DATABASE <font color="#000080">= </font>数据库名称<br />            <font color="#8000ff">%&gt;<br />            </font></td>        </tr>    </tbody></table></p><p>建立记录集对象： </p><p><table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">    <tbody>        <tr>            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font color="#8000ff">&lt;%<br />            </font><font color="#0000ff">Set </font>rs <font color="#000080">= </font>server<font color="#000080">.</font>CreateObject<font color="#000080">(</font>adodb<font color="#000080">.</font>recordset<font color="#000080">)<br />            </font>rs<font color="#000080">.</font>Open <font color="#800000">&quot;SQL语句&quot;</font><font color="#000080">, </font>conn<font color="#000080">, </font><font color="#800080">3</font><font color="#000080">, </font><font color="#800080">2<br />            </font><font color="#8000ff">%&gt;</font></td>        </tr>    </tbody></table></p><p>&nbsp;</p><p><strong>18. SQL常用命令使用方法：</strong> </p><p>(1) 数据记录筛选： </p><p>sql=select * from 数据表 where 字段名=字段值 order by 字段名 [desc] </p><p>sql=select * from 数据表 where 字段名 like '%字段值%' order by 字段名 [desc] </p><p>sql=select top 10 * from 数据表 where 字段名 order by 字段名 [desc] </p><p>sql=select * from 数据表 where 字段名 in ('值1','值2','值3') </p><p>sql=select * from 数据表 where 字段名 between 值1 and 值2 </p><p>(2) 更新数据记录： </p><p>sql=update 数据表 set 字段名=字段值 where 条件表达式 </p><p>sql=update 数据表 set 字段1=值1,字段2=值2 &hellip;&hellip; 字段n=值n where 条件表达式 </p><p>(3) 删除数据记录： </p><p>sql=delete from 数据表 where 条件表达式 </p><p>sql=delete from 数据表 (将数据表所有记录删除) </p><p>(4) 添加数据记录： </p><p>sql=insert into 数据表 (字段1,字段2,字段3 &hellip;) valuess (值1,值2,值3 &hellip;) </p><p>sql=insert into 目标数据表 select * from 源数据表 (把源数据表的记录添加到目标数据表) </p><p>(5) 数据记录统计函数： </p><p>AVG(字段名) 得出一个表格栏平均值 <br />COUNT(*|字段名) 对数据行数的统计或对某一栏有值的数据行数统计 <br />MAX(字段名) 取得一个表格栏最大的值 <br />MIN(字段名) 取得一个表格栏最小的值 <br />SUM(字段名) 把数据栏的值相加 </p><p>引用以上函数的方法： </p><p>sql=select sum(字段名) as 别名 from 数据表 where 条件表达式 <br />set rs=conn.excute(sql) </p><p>用 rs(别名) 获取统的计值，其它函数运用同上。 </p><p>(5) 数据表的建立和删除： </p><p>CREATE TABLE 数据表名称(字段1 类型1(长度),字段2 类型2(长度) &hellip;&hellip; ) </p><p>例：CREATE TABLE tab01(name varchar(50),datetime default now()) </p><p>DROP TABLE 数据表名称 (永久性删除一个数据表)</p><p>&nbsp;</p><p><strong>19. 记录集对象的方法：</strong> </p><p><table cellspacing="3" cellpadding="2" align="center" border="1">    <tbody>        <tr>            <td>rs.movenext</td>            <td>将记录指针从当前的位置向下移一行</td>        </tr>        <tr>            <td>rs.moveprevious</td>            <td>将记录指针从当前的位置向上移一行</td>        </tr>        <tr>            <td>rs.movefirst</td>            <td>将记录指针移到数据表第一行</td>        </tr>        <tr>            <td>rs.movelast</td>            <td>将记录指针移到数据表最后一行</td>        </tr>        <tr>            <td>rs.absoluteposition=N</td>            <td>将记录指针移到数据表第N行</td>        </tr>        <tr>            <td>rs.absolutepage=N</td>            <td>将记录指针移到第N页的第一行</td>        </tr>        <tr>            <td>rs.pagesize=N</td>            <td>设置每页为N条记录</td>        </tr>        <tr>            <td>rs.pagecount</td>            <td>根据pagesize的设置返回总页数</td>        </tr>        <tr>            <td>rs.recordcount</td>            <td>返回记录总数</td>        </tr>        <tr>            <td>rs.bof</td>            <td>返回记录指针是否超出数据表首端，true表示是，false为否</td>        </tr>        <tr>            <td>rs.eof</td>            <td>返回记录指针是否超出数据表末端，true表示是，false为否</td>        </tr>        <tr>            <td>rs.delete</td>            <td>删除当前记录，但记录指针不会向下移动</td>        </tr>        <tr>            <td>rs.addnew</td>            <td>添加记录到数据表末端</td>        </tr>        <tr>            <td>rs.update</td>            <td>更新数据表记录</td>        </tr>    </tbody></table></p><p>－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－</p><p>&nbsp;</p><p><strong>20 Recordset对象方法</strong></p><p>Open方法 </p><p>recordset.Open Source,ActiveConnection,CursorType,LockType,Options </p><p>Source <br />Recordset对象可以通过Source属性来连接Command对象。Source参数可以是一个Command对象名称、一段SQL命令、一个指定的数据表名称或是一个Stored Procedure。假如省略这个参数，<a title="25175学生成绩管理查询系统" href="http://www.25175.com/">系统</a>则采用Recordset对象的Source属性。 </p><p>ActiveConnection <br />Recordset对象可以通过ActiveConnection属性来连接Connection对象。这里的ActiveConnection可以是一个Connection对象或是一串包含数据库连接信息（ConnectionString）的字符串参数。 </p><p>CursorType <br />Recordset对象Open方法的CursorType参数表示将以什么样的游标类型启动数据，包括adOpenForwardOnly、adOpenKeyset、adOpenDynamic及adOpenStatic，分述如下： <br /><br /><table cellspacing="3" cellpadding="2" align="center" border="1">    <tbody>        <tr bgcolor="#ddddff">            <td>常数</td>            <td>常数值</td>            <td>说明</td>        </tr>        <tr>            <td>adOpenForwardOnly</td>            <td>0</td>            <td>缺省值，启动一个只能向前移动的游标（ForwardOnly）。</td>        </tr>        <tr>            <td>adOpenKeyset</td>            <td>1</td>            <td>启动一个Keyset类型的游标。</td>        </tr>        <tr>            <td>adOpenDynamic</td>            <td>2</td>            <td>启动一个Dynamic类型的游标。</td>        </tr>        <tr>            <td>adOpenStatic</td>            <td>3</td>            <td>启动一个Static类型的游标。</td>        </tr>    </tbody></table><br /><br />以上几个游标类型将直接影响到Recordset对象所有的属性和方法，以下列表说明他们之间的区别。 </p><p><table cellspacing="3" cellpadding="2" align="center" border="1">    <tbody>        <tr bgcolor="#ddddff">            <td>Recordset属性</td>            <td>adOpenForwardOnly</td>            <td>adOpenKeyset</td>            <td>adOpenDynamic</td>            <td>adOpenStatic</td>        </tr>        <tr>            <td>AbsolutePage</td>            <td>不支持</td>            <td>不支持</td>            <td>可读写</td>            <td>可读写</td>        </tr>        <tr>            <td>AbsolutePosition</td>            <td>不支持</td>            <td>不支持</td>            <td>可读写</td>            <td>可读写</td>        </tr>        <tr>            <td>ActiveConnection</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>        </tr>        <tr>            <td>BOF</td>            <td>只读</td>            <td>只读</td>            <td>只读</td>            <td>只读</td>        </tr>        <tr>            <td>Bookmark</td>            <td>不支持</td>            <td>不支持</td>            <td>可读写</td>            <td>可读写</td>        </tr>        <tr>            <td>CacheSize</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>        </tr>        <tr>            <td>CursorLocation</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>        </tr>        <tr>            <td>CursorType</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>        </tr>        <tr>            <td>EditMode</td>            <td>只读</td>            <td>只读</td>            <td>只读</td>            <td>只读</td>        </tr>        <tr>            <td>EOF</td>            <td>只读</td>            <td>只读</td>            <td>只读</td>            <td>只读</td>        </tr>        <tr>            <td>Filter</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>        </tr>        <tr>            <td>LockType</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>        </tr>        <tr>            <td>MarshalOptions</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>        </tr>        <tr>            <td>MaxRecords</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>        </tr>        <tr>            <td>PageCount</td>            <td>不支持</td>            <td>不支持</td>            <td>只读</td>            <td>只读</td>        </tr>        <tr>            <td>PageSize</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>        </tr>        <tr>            <td>RecordCount</td>            <td>不支持</td>            <td>不支持</td>            <td>只读</td>            <td>只读</td>        </tr>        <tr>            <td>Source</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>            <td>可读写</td>        </tr>        <tr>            <td>State</td>            <td>只读</td>            <td>只读</td>            <td>只读</td>            <td>只读</td>        </tr>        <tr>            <td>Status</td>            <td>只读</td>            <td>只读</td>            <td>只读</td>            <td>只读</td>        </tr>        <tr>            <td>AddNew</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>CancelBatch</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>CancelUpdate</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>Clone</td>            <td>不支持</td>            <td>不支持</td>            <td>不支持</td>            <td>不支持</td>        </tr>        <tr>            <td>Close</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>Delete</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>GetRows</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>Move</td>            <td>不支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>MoveFirst</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>MoveLast</td>            <td>不支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>MoveNext</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>MovePrevious</td>            <td>不支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>NextRecordset</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>Open</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>Requery</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>Resync</td>            <td>不支持</td>            <td>不支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>Supports</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>Update</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>        <tr>            <td>UpdateBatch</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>            <td>支持</td>        </tr>    </tbody></table><br />其中NextRecordset方法并不适用于Microsoft Access数据库。 </p><p>LockType <br />Recordset对象Open方法的LockType参数表示要采用的Lock类型，如果忽略这个参数，那么<a title="25175学生成绩管理查询系统" href="http://www.25175.com/">系统</a>会以Recordset对象的LockType属性为预设值。LockType参数包含adLockReadOnly、adLockPrssimistic、adLockOptimistic及adLockBatchOptimistic等，分述如下：<table cellspacing="3" cellpadding="2" align="center" border="1">    <tbody>        <tr bgcolor="#ddddff">            <td>常数</td>            <td>常数值</td>            <td>说明</td>        </tr>        <tr>            <td>adLockReadOnly</td>            <td>1</td>            <td>缺省值，Recordset对象以只读方式启动，无法运行AddNew、Update及Delete等方法</td>        </tr>        <tr>            <td>adLockPrssimistic</td>            <td>2</td>            <td>当数据源正在更新时，<a title="25175学生成绩管理查询系统" href="http://www.25175.com/">系统</a>会暂时锁住其他用户的动作，以保持数据一致性。</td>        </tr>        <tr>            <td>adLockOptimistic</td>            <td>3</td>            <td>当数据源正在更新时，<a title="25175学生成绩管理查询系统" href="http://www.25175.com/">系统</a>并不会锁住其他用户的动作，其他用户可以对数据进行增、删、改的操作。</td>        </tr>        <tr>            <td>adLockBatchOptimistic</td>            <td>4</td>            <td>当数据源正在更新时，其他用户必须将CursorLocation属性改为adUdeClientBatch才能对数据进行增、删、改的操作。</td>        </tr>    </tbody></table><br /></p><p><br /></p>]]></description><category>asp</category><comments>http://blog.cnxcn.net/post/190.html#comment</comments><wfw:comment>http://blog.cnxcn.net/</wfw:comment><wfw:commentRss>http://blog.cnxcn.net/feed.asp?cmt=190</wfw:commentRss><trackback:ping>http://blog.cnxcn.net/cmd.asp?act=tb&amp;id=190&amp;key=90cde1af</trackback:ping></item><item><title>ASP六大对象全面讲解</title><author>peijialai@qingdaotse.com (文心春萌)</author><link>http://blog.cnxcn.net/post/189.html</link><pubDate>Wed, 13 Jun 2007 15:52:00 +0800</pubDate><guid>http://blog.cnxcn.net/post/189.html</guid><description><![CDATA[ASP六大对象全面讲解<br /><br />Application对象&nbsp;&nbsp;<br />　　Application对象是个应用程序级的对象，用来在所有用户间共享信息，并可以在Web应用程序运行期间持久地保持数据。&nbsp;<br />Application的属性：&nbsp;<br />　　方法如下：&nbsp;&nbsp;<br />　　Application对象没有内置的属性，但是我们可以自行创建其属性。&nbsp;<br />　　&lt;%&nbsp;Application(&quot;属性名&quot;)=值&nbsp;%&gt;&nbsp;&nbsp;<br />　　其实大部分Application变量都　存放在Contents集合中，当你创建一个新的Application变量时，其实就是在Contents集合中添加了一项。下面两个脚本是等效的：&nbsp;&nbsp;<br />　　&lt;%&nbsp;Application(&quot;greeting&quot;)=&quot;hello!&quot;&nbsp;%&gt;&nbsp;或&nbsp;&lt;%&nbsp;&nbsp;Application.contents(&quot;greeting&quot;)=&quot;hello!&quot;由于Application变量存在集合里，所以如果想要全部显示，其方法我们已经多次使用，例如For&nbsp;Each循环。　　&nbsp;&nbsp;<br />&lt;%&nbsp;<br />For&nbsp;Each&nbsp;item&nbsp;IN&nbsp;Application.Contents&nbsp;<br />&nbsp;&nbsp;Response.write(&quot;&lt;br&gt;&quot;&amp;item&amp;Application.Contents(item))&nbsp;<br />next&nbsp;<br />%&gt;&nbsp;&nbsp;<br />Application的方法：&nbsp;&nbsp;<br />　　Application的方法只有两个方法：一个是Lock，另一个是Unlock。其中Lock方法用于保证同一时刻只能一个用户对Application操作。Unlock则用于取消Lock方法的限制。如：&nbsp;<br />&lt;%&nbsp;<br />Application.Lock&nbsp;<br />Application(&quot;visitor_num&quot;)=Application(&quot;visitor_num&quot;)+1&nbsp;<br />Application.Unlock&nbsp;<br />%&gt;&nbsp;&nbsp;<br />Application的事件：&nbsp;&nbsp;<br />1、Application_OnStart()&nbsp;&nbsp;<br />　　当事件应用程序启动时触发。&nbsp;&nbsp;<br />2、Application_OnEnd()&nbsp;<br />　　此事件应用程序结束时触发。&nbsp;&nbsp;<br />　　这两个事件过程都是必须定义在Global.asp文件中，一般把连接数据的函数定义在这两个事件，然后放在Global.asp中。例如：&nbsp;<br />Sub&nbsp;Application_OnStart&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;Application(&quot;tt18_ConnectionString&quot;)&nbsp;=&nbsp;&quot;driver={SQL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Server};server=jeff;uid=sa;pwd=;database=test&quot;&nbsp;&nbsp;<br />End&nbsp;Sub&nbsp;&nbsp;<br />　　一个数组能够被定义成Application对象，不过这个数组只能作为一个对象保存，而不能用Application(0)取出其值。可以定义一个临时数组实现这种功能。如：&nbsp;<br />&lt;%&nbsp;<br />dim&nbsp;Array()&nbsp;<br />Array=Application(&quot;array&quot;)&nbsp;<br />for&nbsp;i&nbsp;=&nbsp;0&nbsp;to&nbsp;ubound(array)&nbsp;<br />&nbsp;&nbsp;Response.write&nbsp;Array(i)&nbsp;<br />next&nbsp;i&nbsp;<br />%&gt;&nbsp;&nbsp;<br />　　同样要修改这个Application对象也可以定义一个临时数组，把Application对象赋给数组，然后修改这个数组的元素，最后把数组赋回Application对象。如：&nbsp;<br />&lt;%&nbsp;<br />dim&nbsp;Array()&nbsp;<br />Array=Application(&quot;array&quot;)&nbsp;<br />Array(0)=&quot;jeff&quot;&nbsp;<br />Array(1)=&quot;zhu&quot;&nbsp;<br />Application.lock&nbsp;<br />Application(&quot;array&quot;)=Array&nbsp;<br />Application.unlock&nbsp;<br />%&gt;&nbsp;<br />ObjectContext对象&nbsp;&nbsp;<br /><br />该对象用于控制Active&nbsp;Server&nbsp;Pages的事务处理。事务处理由Microsoft&nbsp;Transaction&nbsp;Server&nbsp;(MTS)管理。&nbsp;&nbsp;<br /><br />事件&nbsp;&nbsp;<br />ObjectContext.OnTransactionAbort&nbsp;&nbsp;<br /><br />由放弃的事务处理事件激发，在脚本完成处理后发生。&nbsp;&nbsp;<br /><br />ObjectContext.OnTransactionCommit&nbsp;&nbsp;<br /><br />由成功的事务处理事件激发，在脚本完成处理后发生。&nbsp;&nbsp;<br /><br />方法&nbsp;&nbsp;<br /><br />ObjectContext.SetAbort&nbsp;&nbsp;<br /><br />显式的放弃一次事务处理。&nbsp;&nbsp;<br /><br />ObjectContext.SetComplete&nbsp;&nbsp;<br /><br />覆盖前面任何调用ObjectContext.SetAbort方法的调用。&nbsp;&nbsp;&nbsp;<br />Request对象&nbsp;<br />&nbsp;&nbsp;&nbsp;<br />Request对象用于接受所有从浏览器发往你的服务器的请求内的所有信息。&nbsp;<br /><br />集合&nbsp;<br /><br />Request.ClientCertificate(key[SubField])&nbsp;<br /><br />所有客户证书的信息的集合。对于Key，该集合具有如下的关键字：&nbsp;<br /><br />Subject&nbsp;<br />证书的主题。包含所有关于证书收据的信息。能和所有的子域后缀一起使用。&nbsp;<br /><br />Issuer&nbsp;<br />证书的发行人。包含所有关于证书验证的信息。除了CN外，能和所有的子域后缀一起使用。&nbsp;<br /><br />VadidFrom&nbsp;<br />证书发行的日期。使用VBScript格式。&nbsp;<br /><br />ValidUntil&nbsp;<br />该证书不在有效的时间。&nbsp;<br /><br />SerialNumber&nbsp;<br />包含该证书的序列号。&nbsp;<br /><br />Certificate&nbsp;<br />包含整个证书内容的二进制流，使用ASN.1格式。&nbsp;<br /><br /><br />对于SubField，Subject和Issuer关键字可以具有如下的子域后缀：（比如：SubjectOU或IssuerL）&nbsp;<br /><br />C&nbsp;<br />起源国家。&nbsp;<br /><br />O&nbsp;<br />公司或组织名称。&nbsp;<br /><br />OU&nbsp;<br />组织单元。&nbsp;<br /><br />CN&nbsp;<br />用户的常规名称。&nbsp;<br /><br />L&nbsp;<br />局部。&nbsp;<br /><br />S&nbsp;<br />州（或省）。&nbsp;<br /><br />T&nbsp;<br />个人或公司的标题。&nbsp;<br /><br />GN&nbsp;<br />给定名称。&nbsp;<br /><br />I&nbsp;<br />初始。&nbsp;<br /><br /><br />当文件cervbs.inc(VBScript使用)或cerjavas.inc(Jscript使用)通过使用#INCLUDE导向包含在你的Active&nbsp;Server&nbsp;Page里时，下面两个标志可以使用：&nbsp;<br /><br />ceCertPresent&nbsp;<br />指明客户证书是否存在，其值为TRUE或FALSE。&nbsp;<br /><br />ceUnrecongnizedIssure&nbsp;<br />指明在该链表中的最后的证书的发行者是否未知，其值为TRUE或FALSE。&nbsp;<br /><br /><br />Request.Cookies(Cookie[(key).Attribute])&nbsp;<br /><br />Cookie&nbsp;的集合。允许获得浏览器的Cookie。Cookie指明返回那一个Cookie。Key用于从Cookie字典中返回具有某一关键字的Cookie值。对于Attribute，你能使用属性HasKeys来确定某一Cookie是否具有子关键字。HasKeys的值为TRUE或FALSE。&nbsp;<br /><br />Request.Form(Parameter)[(Index).Count]&nbsp;<br /><br />填写在HTML的表单中所有的数据的集合。Parameter是在HTML表单中某一元素的名称。当某一参数具有不止一个值（比如，当在&lt;Select&gt;中使用MULTIPLE属性时）时，使用Index。当某一参数具有多值时，Count指明多值个数。&nbsp;<br /><br />Request.QueryString(Varible)[(Index).Count]&nbsp;<br /><br />查询字符串的所有值的集合。Varible是在查询字符串某一变量的名称。当某一变量具有多于一个值时，使用Index。当某一参数具有多值时，Count指明值的个数。&nbsp;<br /><br />Request.ServerVaribles(Server&nbsp;Environment&nbsp;Variable)&nbsp;<br /><br />环境变量的集合。允许读取HTTP头。你可以通过使用HTTP_前缀来读取任何头信息。比如，HTTP_USER_AGENT接受客户代理HTTP头（浏览器类型）。除此外，你可以使用下表所示的变量获得任何环境信息。&nbsp;<br /><br />ALL_HTTP&nbsp;<br />客户端发送的所有HTTP标头，他的结果都有前缀HTTP_。&nbsp;<br /><br />ALL_RAW&nbsp;<br />客户端发送的所有HTTP标头,其结果和客户端发送时一样，没有前缀HTTP_&nbsp;&nbsp;<br /><br />APPL_MD_PATH&nbsp;<br />应用程序的元数据库路径。&nbsp;<br /><br />APPL_PHYSICAL_PATH&nbsp;<br />与应用程序元数据库路径相应的物理路径。&nbsp;<br /><br />AUTH_PASSWORD&nbsp;<br />当使用基本验证模式时，客户在密码对话框中输入的密码。&nbsp;<br /><br />AUTH_TYPE&nbsp;<br />这是用户访问受保护的脚本时，服务器用于检验用户的验证方法。&nbsp;<br /><br />AUTH_USER&nbsp;<br />代验证的用户名。&nbsp;<br /><br />CERT_COOKIE&nbsp;<br />唯一的客户证书ID号。&nbsp;<br /><br />CERT_FLAG&nbsp;<br />客户证书标志，如有客户端证书，则bit0为0。如果客户端证书验证无效，bit1被设置为1。&nbsp;<br /><br />CERT_ISSUER&nbsp;<br />用户证书中的发行者字段。&nbsp;<br /><br />CERT_KEYSIZE&nbsp;<br />安全套接字层连接关键字的位数，如128。&nbsp;<br /><br />CERT_SECRETKEYSIZE&nbsp;<br />服务器验证私人关键字的位数。如1024。&nbsp;<br /><br />CERT_SERIALNUMBER&nbsp;<br />客户证书的序列号字段。&nbsp;<br /><br />CERT_SERVER_ISSUER&nbsp;<br />服务器证书的发行者字段&nbsp;<br /><br />CERT_SERVER_SUBJECT&nbsp;<br />服务器证书的主题字段。&nbsp;<br /><br />CERT_SUBJECT&nbsp;<br />客户端证书的主题字段。&nbsp;<br /><br />CONTENT_LENGTH&nbsp;<br />客户端发出内容的长度。&nbsp;<br /><br />CONTENT_TYPE&nbsp;<br />客户发送的form内容或HTTP&nbsp;PUT的数据类型。&nbsp;<br /><br />GATEWAY_INTERFACE&nbsp;<br />服务器使用的网关界面。&nbsp;<br /><br />HTTPS&nbsp;<br />如果请求穿过安全通道（SSL），则返回ON。如果请求来自非安全通道，则返回OFF。&nbsp;<br /><br />HTTPS_KEYSIZE&nbsp;<br />安全套接字层连接关键字的位数，如128。&nbsp;<br /><br />HTTPS_SECRETKEYSIZE&nbsp;<br />服务器验证私人关键字的位数。如1024。&nbsp;<br /><br />HTTPS_SERVER_ISSUER&nbsp;<br />服务器证书的发行者字段。&nbsp;<br /><br />HTTPS_SERVER_SUBJECT&nbsp;<br />服务器证书的主题字段。&nbsp;<br /><br />INSTANCE_ID&nbsp;<br />IIS实例的ID号。&nbsp;<br /><br />INSTANCE_META_PATH&nbsp;<br />响应请求的IIS实例的元数据库路径。&nbsp;<br /><br />LOCAL_ADDR&nbsp;<br />返回接受请求的服务器地址。&nbsp;<br /><br />LOGON_USER&nbsp;<br />用户登录Windows&nbsp;NT的帐号&nbsp;<br /><br />PATH_INFO&nbsp;<br />客户端提供的路径信息。&nbsp;<br /><br />PATH_TRANSLATED&nbsp;<br />通过由虚拟至物理的映射后得到的路径。&nbsp;<br /><br />QUERY_STRING&nbsp;<br />查询字符串内容。&nbsp;<br /><br />REMOTE_ADDR&nbsp;<br />发出请求的远程主机的IP地址。&nbsp;<br /><br />REMOTE_HOST&nbsp;<br />发出请求的远程主机名称。&nbsp;<br /><br />REQUEST_METHOD&nbsp;<br />提出请求的方法。比如GET、HEAD、POST等等。&nbsp;<br /><br />SCRIPT_NAME&nbsp;<br />执行脚本的名称。&nbsp;<br /><br />SERVER_NAME&nbsp;<br />服务器的主机名、DNS地址或IP地址。&nbsp;<br /><br />SERVER_PORT&nbsp;<br />接受请求的服务器端口号。&nbsp;<br /><br />SERVER_PORT_SECURE&nbsp;<br />如果接受请求的服务器端口为安全端口时，则为1，否则为0。&nbsp;<br /><br />SERVER_PROTOCOL&nbsp;<br />服务器使用的协议的名称和版本。&nbsp;<br /><br />SERVER_SOFTWARE&nbsp;<br />应答请求并运行网关的服务器软件的名称和版本。&nbsp;<br /><br />URL&nbsp;<br />提供URL的基本部分。&nbsp;<br /><br /><br />　&nbsp;<br /><br />方法&nbsp;<br /><br />Request.BinaryRead(Count)&nbsp;<br /><br />接收一个HTML表单的未经过处理的内容。当调用此方法时，Count指明要接收多少字节。在调用此方法后，Count指明实际上接收到多少个字节。&nbsp;<br /><br />属性&nbsp;<br /><br />Request.TotalBytes&nbsp;<br /><br />查询体的长度，以字节为单位&nbsp;<br />Response对象&nbsp;<br /><br />　　Response对象用于向客户端浏览器发送数据，用户可以使用该对象将服务器的数据以HTML的格式发送到用户端的浏览器，它与Request组成了一对接收、发送数据的对象，这也是实现动态的基础。下面介绍它常用的属性和方法。&nbsp;<br /><br />&nbsp;&nbsp;<br /><br />1、Buffer属性　　&nbsp;<br />　　该属性用于指定页面输出时是否要用到缓冲区，默认值为False。当它为True时，直到整个Active&nbsp;Server&nbsp;Page执行结束后才会将结果输出到浏览器上。如：&nbsp;<br />&lt;%Response.Buffer=True%&gt;&nbsp;<br />&lt;html&gt;&nbsp;<br />&lt;Head&gt;&nbsp;<br />&lt;title&gt;Buffer示例&lt;/title&gt;&nbsp;<br />&lt;/head&gt;&nbsp;<br />&lt;body&gt;&nbsp;<br />&lt;%&nbsp;<br />&nbsp;&nbsp;for&nbsp;i=1&nbsp;to&nbsp;500&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;response.write(i&nbsp;&amp;&nbsp;&quot;&lt;br&gt;&quot;)&nbsp;<br />&nbsp;&nbsp;next&nbsp;<br />%&gt;&nbsp;<br />&lt;/body&gt;&nbsp;<br />&lt;/html&gt;&nbsp;&nbsp;<br />　　这页执行时，整个主页的所有内容会同时显示在浏览器上，这个主页会存在缓存区中直到脚本执行结束。&nbsp;<br /><br />&nbsp;&nbsp;<br /><br />2、Expires属性&nbsp;<br />　　该属性用于设置浏览器缓存页面的时间长度（单位为分），必须在服务器端刷新。通过如下设置：&nbsp;<br />&lt;%Response.Expires=0%&gt;&nbsp;&nbsp;<br />　　通过在ASP文件中加入这一行代码，要求每次请求是刷新页面，因为Response一收到页面就会过期。&nbsp;<br /><br />&nbsp;&nbsp;<br /><br />3、Write方法&nbsp;<br />　　该方法把数据发送到客户端浏览器，如：　　&nbsp;<br />&lt;%Response.write&nbsp;&quot;Hello,world!&quot;%&gt;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;<br /><br />4、Redirect方法&nbsp;<br />　　该方法使浏览器可以重新定位到另一个URL上，这样，当客户发出Web请求时，客户端的浏览器类型已经确定，客户被重新定位到相应的页面。如：&nbsp;<br />&lt;html&gt;&nbsp;<br />&lt;head&gt;&nbsp;<br />&lt;title&gt;Redirect示例&lt;/title&gt;&nbsp;<br />&lt;/head&gt;&nbsp;<br />&lt;body&gt;&nbsp;<br />&lt;form&nbsp;aciton=&quot;formjump.asp&quot;&nbsp;method=&quot;post&quot;&gt;&nbsp;<br />&nbsp;&nbsp;&lt;select&nbsp;name=&quot;wheretogo&quot;&gt;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&nbsp;selected&nbsp;value=&quot;fun&quot;&gt;Fun&lt;/option&gt;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&nbsp;value=&quot;news&quot;&gt;News&lt;/option&gt;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&nbsp;value=&quot;sample&quot;&gt;Sample&lt;/option&gt;&nbsp;<br />&nbsp;&nbsp;&lt;/select&gt;&nbsp;<br />&lt;input&nbsp;type=submit&nbsp;name=&quot;jump&quot;&nbsp;value=&quot;Jump&quot;&gt;&nbsp;<br />&lt;/form&gt;&nbsp;<br />&lt;/body&gt;&nbsp;<br />&lt;/html&gt;&nbsp;&nbsp;<br />　　以上是提交的表单，下面是处理表单的文件formjump.asp：&nbsp;<br />&lt;%response.buff=true%&gt;&nbsp;<br />&lt;html&gt;&nbsp;<br />&lt;head&gt;&nbsp;<br />&lt;title&gt;Redirect示例&lt;/title&gt;&nbsp;<br />&lt;/head&gt;&nbsp;<br />&lt;body&gt;&nbsp;<br />&lt;%&nbsp;<br />thisurl=&quot;<a href="http://www.tinyu.com/" target="_blank">http://www.tinyu.com/</a>&quot;;&nbsp;<br />where=Request.form(&quot;wheretogo&quot;)&nbsp;<br />Select&nbsp;Case&nbsp;where&nbsp;<br />&nbsp;&nbsp;case&nbsp;&quot;fun&quot;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;response.redirect&nbsp;thisurl&nbsp;&amp;&nbsp;&quot;/fun/default.asp&quot;&nbsp;<br />&nbsp;&nbsp;case&nbsp;&quot;news&quot;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;response.redirect&nbsp;thisurl&nbsp;&amp;&nbsp;&quot;/news/default.asp&quot;&nbsp;<br />&nbsp;&nbsp;case&nbsp;&quot;sample&quot;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;response.redirect&nbsp;thisurl&nbsp;&amp;&nbsp;&quot;/sample/default.asp&quot;&nbsp;<br />End&nbsp;Select&nbsp;<br />%&gt;&nbsp;<br />&lt;/body&gt;&nbsp;<br />&lt;html&gt;&nbsp;&nbsp;<br />　　这个例子当用户选择了以后，按&quot;Jump&quot;按钮提交表单，服务器接到申请后调用formjump.asp判断后定位到相应的URL。不过这里有一点要注意，HTTP标题已经写入到客户浏览器，任何HTTP标题的修改必须在写入页内容之前，遇到这种问题时，可以如下做：&nbsp;<br />在文件的开始&lt;@&nbsp;Language=..&gt;后写：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;Response.Buffer=True&nbsp;<br />在结尾定：&nbsp;<br />&nbsp;&nbsp;Response.Flush&nbsp;<br />　　这里Flush是Response的一个方法，它必须是Buffer属性设置为True时才能使用，否则会产生一个运行模式错误。另外一个Clear方法也是用于清除被缓存的页面，同样要Buffer属性设置为True时才能使用。&nbsp;<br /><br />&nbsp;&nbsp;<br /><br />5、End方法&nbsp;<br />　　该方法用于告知Active&nbsp;Server当遇到该方法时停止处理ASP文件。如果Response对象的Buffer属性设置为True，这时End&nbsp;方法即把缓存中的内容发送到客户并清除冲区。所以要取消所有向客户的输出民，可以先清除缓冲区，然后利用End方法。如：&nbsp;<br />&lt;%&nbsp;<br />Response.buffer=true&nbsp;<br />On&nbsp;error&nbsp;resume&nbsp;next&nbsp;<br />Err.clear&nbsp;<br />if&nbsp;Err.number&lt;&gt;0&nbsp;then&nbsp;<br />&nbsp;&nbsp;Response.Clear&nbsp;<br />&nbsp;&nbsp;Response.End&nbsp;<br />end&nbsp;if&nbsp;<br />%&gt;&nbsp;&nbsp;<br />Server&nbsp;对象:&nbsp;<br /><br />Server&nbsp;对象提供对服务器上的方法和属性的访问。其中大多数方法和属性是作为实用程序的功能服务的。&nbsp;<br /><br />语法&nbsp;&nbsp;<br /><br />Server.property|method&nbsp;<br /><br />属性&nbsp;<br /><br />ScriptTimeout:&nbsp;<br />ScriptTimeout&nbsp;属性指定脚本在结束前最大可运行多长时间。&nbsp;当处理服务器组件时，超时限制将不再生效。&nbsp;&nbsp;<br /><br />语法&nbsp;&nbsp;Server.ScriptTimeout&nbsp;=&nbsp;NumSeconds&nbsp;<br /><br />参数&nbsp;&nbsp;NumSeconds&nbsp;&nbsp;<br />指定脚本在被服务器结束前最大可运行的秒数。默认值为&nbsp;90&nbsp;秒。&nbsp;&nbsp;<br /><br />注释&nbsp;<br />通过使用元数据库中的AspScriptTimeout属性可以为&nbsp;Web&nbsp;服务或&nbsp;Web&nbsp;服务器设置缺省的ScriptTimeout值。&nbsp;ScriptTimeout属性不能设置为小于在元数据库中指定的值。例如，如果NumSeconds设置为10，而元数据库设置包含了默认值90秒，则脚本在90秒后超时。但如果NumSeconds设置为100，则脚本在100秒后超时。&nbsp;<br /><br />关于使用元数据库的详细信息，参阅&nbsp;关于元数据库。&nbsp;<br /><br />示例&nbsp;&nbsp;&nbsp;&nbsp;以下示例中，如果服务器处理脚本超过&nbsp;100&nbsp;秒，将使之超时。&nbsp;<br />&lt;%&nbsp;Server.ScriptTimeout&nbsp;=&nbsp;100&nbsp;%&gt;&nbsp;<br />以下示例获取&nbsp;ScriptTimeout&nbsp;属性当前值，并将其存储在变量&nbsp;TimeOut&nbsp;中。&nbsp;<br />&lt;%&nbsp;TimeOut&nbsp;=&nbsp;Server.ScriptTimeout&nbsp;%&gt;&nbsp;<br /><br />方法&nbsp;<br /><br />CreateObject&nbsp;&nbsp;<br />CreateObject&nbsp;方法创建服务器组件的实例。如果该组件执行了&nbsp;OnStartPage&nbsp;和&nbsp;OnEndPage&nbsp;方法，则此时就会调用&nbsp;OnStartPage&nbsp;方法。有关服务器组件的详细信息，请参阅&nbsp;可安装的&nbsp;ASP&nbsp;组件&nbsp;。&nbsp;<br /><br />语法&nbsp;&nbsp;Server.CreateObject(&nbsp;progID&nbsp;)&nbsp;<br /><br />参数&nbsp;progID&nbsp;指定要创建的对象的类型。progID&nbsp;的格式为&nbsp;[Vendor.]&nbsp;component[.Version]。&nbsp;<br /><br />注释&nbsp;默认情况下，由&nbsp;Server.CreateObject&nbsp;方法创建的对象具有页作用域。这就是说，再当前&nbsp;ASP&nbsp;页处理完成之后，服务器将自动破坏这些对象。要创建有会话或应用程序作用域的对象，可以使用&nbsp;&lt;OBJECT&gt;&nbsp;标记并设置&nbsp;SESSION&nbsp;或&nbsp;APPLICATION&nbsp;&nbsp;的&nbsp;SCOPE&nbsp;属性，也可以在对话及应用程序变量中存储该对象。&nbsp;<br />例如，在如下所示的脚本中，当&nbsp;Session&nbsp;对象被破坏，即当对话超时时或&nbsp;Abandon&nbsp;方法被调用时，存储在会话变量中的对象也将被破坏。&nbsp;<br />&lt;%&nbsp;Set&nbsp;Session(&quot;ad&quot;)&nbsp;=&nbsp;Server.CreateObject(&quot;MSWC.AdRotator&quot;)%&gt;&nbsp;<br />可以通过将变量设置为&nbsp;Nothing&nbsp;或新的值来破坏对象，如下所示。第一个例子释放&nbsp;ad&nbsp;对象，第二个例子用字串代替&nbsp;ad&nbsp;。&nbsp;<br />&lt;%&nbsp;Session&nbsp;(&quot;ad&quot;)&nbsp;=&nbsp;Nothing&nbsp;%&gt;&nbsp;<br />&lt;%&nbsp;Session&nbsp;(&quot;ad&quot;)&nbsp;=&nbsp;&quot;&nbsp;Other&nbsp;Valum&nbsp;&quot;&nbsp;%&gt;&nbsp;<br />不能创建与内建对象同名的对象实例。&nbsp;例如，下列脚本将返回错误。&nbsp;<br />&lt;%&nbsp;Set&nbsp;Response&nbsp;=&nbsp;Server.CreateObject(&quot;Response&quot;)&nbsp;%&gt;&nbsp;&nbsp;<br /><br />示例&nbsp;&nbsp;&lt;%&nbsp;Set&nbsp;MyAd&nbsp;=&nbsp;Server.CreateObject(&quot;MSWC.AdRotator&quot;)&nbsp;%&gt;&nbsp;&nbsp;<br />上面的例子创建一个名为&nbsp;MyAd&nbsp;的&nbsp;MSWC.AdRotator&nbsp;服务器组件，MSWC.AdRotator&nbsp;组件可用于在&nbsp;Web&nbsp;页上的自动轮换广告。&nbsp;<br />关于服务器组件的详细信息,&nbsp;请参阅&nbsp;Creating&nbsp;Components&nbsp;for&nbsp;ASP.&nbsp;<br /><br />HTMLEncode&nbsp;&nbsp;HTMLEncode方法对指定的字符串应用&nbsp;HTML&nbsp;编码。&nbsp;&nbsp;<br /><br />语法&nbsp;&nbsp;&nbsp;&nbsp;Server.HTMLEncode(&nbsp;string&nbsp;)&nbsp;<br /><br />参数&nbsp;&nbsp;&nbsp;&nbsp;string&nbsp;指定要编码的字符串。&nbsp;&nbsp;<br /><br />示例脚本&nbsp;&nbsp;&nbsp;&nbsp;&lt;%=&nbsp;Server.HTMLEncode(&quot;The&nbsp;paragraph&nbsp;tag:&nbsp;&lt;P&gt;&quot;)&nbsp;%&gt;&nbsp;&nbsp;<br /><br />输出&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;paragraph&nbsp;tag:&nbsp;&lt;P&gt;&nbsp;&nbsp;<br /><br />注意&nbsp;以上输出将被&nbsp;Web&nbsp;浏览器显示为The&nbsp;paragraph&nbsp;tag:&nbsp;&lt;P&gt;如果查看一下源文件或以文本方式打开一个&nbsp;Web&nbsp;页，您就可以看到已编码的&nbsp;HTML。&nbsp;<br /><br /><br />MapPath&nbsp;<br />MapPath&nbsp;方法将指定的相对或虚拟路径映射到服务器上相应的物理目录上。&nbsp;<br /><br />语法&nbsp;<br />Server.MapPath(&nbsp;Path&nbsp;)&nbsp;<br /><br />参数&nbsp;<br />Path&nbsp;&nbsp;<br />指定要映射物理目录的相对或虚拟路径。若&nbsp;Path&nbsp;以一个正斜杠&nbsp;(/)&nbsp;或反斜杠&nbsp;(\)&nbsp;开始，则&nbsp;MapPath&nbsp;方法返回路径时将&nbsp;Path&nbsp;视为完整的虚拟路径。若&nbsp;Path&nbsp;不是以斜杠开始，则&nbsp;MapPath&nbsp;方法返回同&nbsp;.asp&nbsp;文件中已有的路径相对的路径。&nbsp;&nbsp;<br />注释&nbsp;<br />MapPath&nbsp;方法不支持相对路径语法&nbsp;(.)&nbsp;或&nbsp;(..)。例如，下列相对路径&nbsp;../MyDir/MyFile.txt&nbsp;返回一个错误。&nbsp;<br /><br />MapPath&nbsp;方法不检查返回的路径是否正确或在服务器上是否存在。&nbsp;<br /><br />因为&nbsp;MapPath&nbsp;方法只映射路径而不管指定的目录是否存在，所以，您可以先用&nbsp;MapPath&nbsp;方法映射物理目录结构的路径，然后将其传递给在服务器上创建指定目录或文件的组件。&nbsp;<br /><br />示例&nbsp;<br />对于下列示例，文件data.txt和包含下列脚本的test.asp文件都位于目录C:\Inetpub\Wwwroot\Script下。C:\Inetpub\Wwwroot目录被设置为服务器的宿主目录。&nbsp;<br /><br />下列示例使用服务器变量&nbsp;PATH_INFO&nbsp;映射当前文件的物理路径。脚本&nbsp;<br />&lt;%=&nbsp;server.mappath(Request.ServerVariables(&quot;PATH_INFO&quot;))%&gt;&lt;BR&gt;&nbsp;<br /><br />输出&nbsp;<br />c:\inetpub\wwwroot\script\test.asp&lt;BR&gt;&nbsp;<br /><br />由于下列示例中的路径参数不是以斜杠字符开始的，所以它们被相对映射到当前目录，此处是&nbsp;C:\Inetpub\Wwwroot\Script。脚本&nbsp;<br />&lt;%=&nbsp;server.mappath(&quot;data.txt&quot;)%&gt;&lt;BR&gt;&nbsp;<br />&lt;%=&nbsp;server.mappath(&quot;script/data.txt&quot;)%&gt;&lt;BR&gt;&nbsp;<br /><br />输出&nbsp;<br />c:\inetpub\wwwroot\script\data.txt&lt;BR&gt;&nbsp;<br />c:\inetpub\wwwroot\script\script\data.txt&lt;BR&gt;&nbsp;<br /><br />接下来的两个示例使用斜杠字符指定返回的路径应被视为在服务器的完整虚拟路径。脚本&nbsp;<br />&lt;%=&nbsp;server.mappath(&quot;/script/data.txt&quot;)%&gt;&lt;BR&gt;&nbsp;<br />&lt;%=&nbsp;server.mappath(&quot;\script&quot;)%&gt;&lt;BR&gt;&nbsp;<br /><br />输出&nbsp;<br />c:\inetpub\script\data.txt&lt;BR&gt;&nbsp;<br />c:\inetpub\script&lt;BR&gt;&nbsp;<br /><br />下列示例演示如何使用正斜杠&nbsp;(/)&nbsp;或反斜杠&nbsp;(\)&nbsp;返回宿主目录的物理路径。脚本&nbsp;<br />&lt;%=&nbsp;server.mappath(&quot;/&quot;)%&gt;&lt;BR&gt;&nbsp;<br />&lt;%=&nbsp;server.mappath(&quot;\&quot;)%&gt;&lt;BR&gt;&nbsp;<br /><br />输出&nbsp;<br />c:\inetpub\wwwroot&lt;BR&gt;&nbsp;<br />c:\inetpub\wwwroot&lt;BR&gt;&nbsp;<br />　&nbsp;<br /><br />URLEncode&nbsp;<br />URLEncode&nbsp;方法将&nbsp;URL&nbsp;编码规则，包括转义字符，应用到指定的字符串。&nbsp;<br /><br />语法&nbsp;<br />Server.URLEncode(&nbsp;string&nbsp;)&nbsp;&nbsp;<br />参数&nbsp;&nbsp;<br />String&nbsp;指定要编码的字符串。&nbsp;&nbsp;<br />示例&nbsp;<br />脚本&nbsp;&lt;%Response.Write(Server.URLEncode(&quot;<a href="http://www.tinyu.com/" target="_blank">http://www.tinyu.com</a>&quot;;))%&gt;&nbsp;<br /><br />输出&nbsp;http%3A%2F%2Fwww%2Etinyu%2Ecom&nbsp;<br />Session对象&nbsp;<br /><br />　　Session其实指的就是访问者从到达某个特定主页到离开为止的那段时间。每一访问者都会单独获得一个Session。在Web应用程序中，当一个用户访问该应用时，Session类型的变量可以供这个用户在该Web应用的所有页面******享数据；如果另一个用户也同时访问该Web应用，他也拥有自己的&nbsp;Session变量，但两个用户之间无法通过Session变量共享信息，而Application类型的变更则可以实现站点多个用户之间在所有页面******享信息。&nbsp;<br /><br />&nbsp;&nbsp;<br /><br />1、SessionID属性&nbsp;<br />　　该属性返回当前会话的唯一标志，为每一个Session分配不同的编号。&nbsp;<br />　　我曾在开发过程中就遇到对用户的控制问题。它要实现的功能就是，针对某个网站的一个模块，当一个会员登录后正在看此模块时，另一个人用同样的会员名登录，就不能浏览这个模块。也就是说一个会员名同时只能一个人浏览此模块。我通过用会员名（假设为UserID，唯一）和SessionID来实现了控制。当会员登录时，给这个会员一个Session记录登录状态如：Session(&quot;Status&quot;)=&quot;Logged&quot;，同时把这个会员的&nbsp;Session.SessionID写入数据库。当他要浏览此模块时，先判断其是否登录，若已经登录再判断它的SessionID是否与数据库记录的相同，如果不同则不能访问。这样，当另一个用户用相同的会员名登录时，那么数据库中记录的就是新的SessionID，前者访问此模块时就不能通过检查。这就实现了一个会员名同时只能一个人浏览某个模块。这个功能在一些收费网站有很有特别作用，它防止了一个会员名给多个人浏览的问题，为公司保障了利益。&nbsp;<br /><br />&nbsp;&nbsp;<br /><br />2、TimeOut属性&nbsp;<br />　　该属性用来定义用户Session对象的时限。如果用户在规定的时间内没有刷新网页，则Session对象就会终止。一般默认为20分钟。　　&nbsp;<br /><br />&nbsp;&nbsp;<br /><br />3、Abandon方法&nbsp;<br />　　该方法是Session对象的唯一方法，可以清除Session对象，用来消除用户的Session对象并释放其所占的资源。如：&nbsp;&lt;%&nbsp;Session.Abandon&nbsp;%&gt;&nbsp;&nbsp;<br />4、Session_OnStart和Session_OnEnd事件&nbsp;<br />　　和Application一样，当对象的例程每一次启动时触发Session_OnStart事件，然后运行Session_Onstart事件的处理过程。也就是说，当服务器接收到应用程序中的URL的HTTP请求时，触发此事件，并建立一个Session对象。同理，这个事件也必须定在&nbsp;Global.asa文件中。&nbsp;<br />　　当调用Session.Abandon方法时或者在TimeOut的时间内没有刷新，这会触发&nbsp;Session_OnEnd事件，然后执行里面的脚本。Session变量与特定的用户相联系，针对某一个用户赋值的Session变量是和其他用户的&nbsp;Session变量完全独立的，不会存在相互影响。&nbsp;<br />Session应用一列：&nbsp;<br />　　与Application一样，一个被定义为&nbsp;Session类型的数组只能将整个数组作为一个对象，用户不能直接改变Session数组中某个元素的值。为了创建一个Session数组，需先定义一个普通的数组，并对它的每一个元素赋初值，最后把它定义为一个Session数组。如：&nbsp;<br />&lt;%&nbsp;<br />dim&nbsp;array()&nbsp;<br />array=array(&quot;李&quot;,&quot;明&quot;,&quot;男&quot;)&nbsp;<br />Session(&quot;info&quot;)=array&nbsp;<br />Response.write&nbsp;Session(&quot;info&quot;)(0)&nbsp;&amp;&quot;-&quot;&nbsp;<br />Response.write&nbsp;Session(&quot;info&quot;)(1)&nbsp;&amp;&quot;-&quot;&nbsp;<br />Response.write&nbsp;Session(&quot;info&quot;)(2)&nbsp;&amp;&quot;&lt;br&gt;&quot;&nbsp;<br />%&gt;&nbsp;<br />&lt;hr&gt;&nbsp;<br />&lt;%&nbsp;<br />array(0)=&quot;天&quot;&nbsp;<br />array(1)=&quot;宇&quot;&nbsp;<br />array(2)=&quot;男&quot;&nbsp;<br />Session(&quot;info&quot;)=array&nbsp;<br />Response.write&nbsp;Session(&quot;info&quot;)(0)&nbsp;&amp;&nbsp;&quot;-&quot;&nbsp;<br />Response.write&nbsp;Session(&quot;info&quot;)(1)&nbsp;&amp;&nbsp;&quot;-&quot;&nbsp;<br />Response.write&nbsp;Session(&quot;info&quot;)(2)&nbsp;&amp;&nbsp;&quot;&lt;br&gt;&quot;&nbsp;<br />%&gt;<br />]]></description><category>asp</category><comments>http://blog.cnxcn.net/post/189.html#comment</comments><wfw:comment>http://blog.cnxcn.net/</wfw:comment><wfw:commentRss>http://blog.cnxcn.net/feed.asp?cmt=189</wfw:commentRss><trackback:ping>http://blog.cnxcn.net/cmd.asp?act=tb&amp;id=189&amp;key=8ff113c3</trackback:ping></item><item><title>一个空间绑定多域名的ASP代码</title><author>peijialai@qingdaotse.com (文心春萌)</author><link>http://blog.cnxcn.net/post/188.html</link><pubDate>Wed, 13 Jun 2007 15:51:12 +0800</pubDate><guid>http://blog.cnxcn.net/post/188.html</guid><description><![CDATA[一个空间绑定多域名的ASP代码<br />作者:Erentan&nbsp;日期:2005年12月8日第一种方法：<br /><br />如果有有一个ASP空间，而你又想放置多个多个站点，这些代码可以帮到你<br />第一个&nbsp;<br />&lt;%if&nbsp;Request.ServerVariables(&quot;SERVER_NAME&quot;)=&quot;www.netbei.com&quot;&nbsp;then<br />response.redirect&nbsp;&quot;zkj&quot;<br />else<br />response.redirect&nbsp;&quot;i.htm&quot;<br />end&nbsp;if%&gt;<br /><br />第二个<br />&lt;%<br />select&nbsp;case&nbsp;request.servervariables(&quot;http_host&quot;)<br />case&nbsp;&quot;www.netbei.com&quot;&nbsp;'1<br />Server.Transfer(&quot;v3.htm&quot;)<br />case&nbsp;&quot;www.aspcn.net&quot;&nbsp;'2<br />Server.Transfer(&quot;i.htm&quot;)<br />case&nbsp;&quot;www.netbei.cn&quot;&nbsp;'3<br />Server.Transfer(&quot;netbei.htm&quot;)<br />......&nbsp;继续添加&nbsp;......<br />end&nbsp;select<br />%&gt;<br /><br />第三个<br />&lt;%if&nbsp;instr(Request.ServerVariables<br />(&quot;SERVER_NAME&quot;),&quot;kekexi.com&quot;)&gt;0&nbsp;then<br />response.redirect&nbsp;&quot;index.asp&quot;<br />else&nbsp;if&nbsp;instr(Request.ServerVariables<br />(&quot;SERVER_NAME&quot;),&quot;4668.com&quot;)&gt;0&nbsp;then<br />response.redirect&nbsp;&quot;x/index.asp&quot;<br />else&nbsp;if&nbsp;instr(Request.ServerVariables<br />(&quot;SERVER_NAME&quot;),&quot;web315.com&quot;)&gt;0&nbsp;thenr<br />esponse.redirect&nbsp;&quot;index3.asp&quot;<br />end&nbsp;if<br />end&nbsp;if<br />end&nbsp;if%&gt;<br /><br />第四个<br />&lt;%if&nbsp;Request.ServerVariables(&quot;SERVER_NAME&quot;)=&quot;www.bkye.com&quot;&nbsp;then<br />response.redirect&nbsp;&quot;index1.asp&quot;<br />else&nbsp;if&nbsp;Request.ServerVariables(&quot;SERVER_NAME&quot;)=&quot;www.jyhao.com&quot;&nbsp;then<br />response.redirect&nbsp;&quot;index2.asp&quot;<br />else&nbsp;if&nbsp;Request.ServerVariables(&quot;SERVER_NAME&quot;)=&quot;www.163.com&quot;&nbsp;then<br />response.redirect&nbsp;&quot;index3.asp&quot;<br />end&nbsp;if<br />end&nbsp;if<br />end&nbsp;if%&gt;&nbsp;<br /><br />第二种方法：<br /><br /><br />&lt;%<br />dim&nbsp;domainname,result<br />domainname=Request.ServerVariables(&quot;SERVER_NAME&quot;)<br />result=right(domainname,12)<br />if&nbsp;result=&quot;my.netbei.com&quot;&nbsp;then&nbsp;<br />%&gt;<br />&lt;!--#include&nbsp;file=mynetbei.asp&nbsp;--&gt;<br />&lt;%<br />Elseif&nbsp;result=&quot;rtisancn.com&quot;&nbsp;then&nbsp;<br />%&gt;<br />&lt;!--#include&nbsp;file=artisan.asp&nbsp;--&gt;<br />&lt;%<br />Elseif&nbsp;result=&quot;gn.netbei.com&quot;&nbsp;then&nbsp;<br />%&gt;<br />&lt;!--#include&nbsp;file=web.asp&nbsp;--&gt;<br />&lt;%<br />Elseif&nbsp;result=&quot;.forwest.com&quot;&nbsp;then&nbsp;<br />%&gt;<br />&lt;!--#include&nbsp;file=forwest_com.asp&nbsp;--&gt;<br />&lt;%<br />Else&nbsp;<br />%&gt;<br />&lt;!--#include&nbsp;file=bkye.asp&nbsp;--&gt;<br />&lt;%<br />End&nbsp;if<br />%&gt;&nbsp;<br /><br />]]></description><category>asp</category><comments>http://blog.cnxcn.net/post/188.html#comment</comments><wfw:comment>http://blog.cnxcn.net/</wfw:comment><wfw:commentRss>http://blog.cnxcn.net/feed.asp?cmt=188</wfw:commentRss><trackback:ping>http://blog.cnxcn.net/cmd.asp?act=tb&amp;id=188&amp;key=d0252b00</trackback:ping></item><item><title>屏蔽IE右键菜单之终极方法</title><author>peijialai@qingdaotse.com (文心春萌)</author><link>http://blog.cnxcn.net/post/187.html</link><pubDate>Wed, 13 Jun 2007 15:50:41 +0800</pubDate><guid>http://blog.cnxcn.net/post/187.html</guid><description><![CDATA[你把下面的代码添加在之间就OK了！<br /><br />&lt;&nbsp;script&nbsp;language=&quot;javascript&quot;&nbsp;id=&quot;clientEventHandlersJS&quot;&gt;&nbsp;<br /><br />&lt;&nbsp;/script&gt;&nbsp;<br /><br />&lt;&nbsp;script&nbsp;language=&quot;javascript&quot;&nbsp;event=&quot;oncontextmenu&quot;&nbsp;for=&quot;document&quot;&gt;&nbsp;<br /><br />&lt;&nbsp;/script&gt;&nbsp;<br />]]></description><category>asp</category><comments>http://blog.cnxcn.net/post/187.html#comment</comments><wfw:comment>http://blog.cnxcn.net/</wfw:comment><wfw:commentRss>http://blog.cnxcn.net/feed.asp?cmt=187</wfw:commentRss><trackback:ping>http://blog.cnxcn.net/cmd.asp?act=tb&amp;id=187&amp;key=d5798b9a</trackback:ping></item><item><title>javascript弹出窗口问题总结</title><author>peijialai@qingdaotse.com (文心春萌)</author><link>http://blog.cnxcn.net/post/186.html</link><pubDate>Wed, 13 Jun 2007 15:46:06 +0800</pubDate><guid>http://blog.cnxcn.net/post/186.html</guid><description><![CDATA[1.无提示刷新网页<br />&nbsp;&nbsp;&nbsp;&nbsp;大家有没有发现，有些网页，刷新的时候，会弹出一个提示窗口，点&ldquo;确定&rdquo;才会刷新。<br />而有的页面不会提示，不弹出提示窗口，直接就刷新了.<br />&nbsp;&nbsp;&nbsp;&nbsp;如果页面没有form,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;则不会弹出提示窗口<br />&nbsp;&nbsp;&nbsp;&nbsp;如果页面有form表单，<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a)&lt;form&nbsp;&nbsp;method=&quot;post&quot;&nbsp;...&gt;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;会弹出提示窗口&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b)&lt;form&nbsp;&nbsp;method=&quot;get&quot;&nbsp;...&gt;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;不会弹出&nbsp;&nbsp;&nbsp;&nbsp;<br /><br /><br />2&nbsp;&nbsp;javascript刷新页面的方法<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;window.location.reload();<br />&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;使用window.open()弹出的弹出窗口，刷新父窗口<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;window.opener.location.reload()<br />&nbsp;&nbsp;&nbsp;使用window.showDialog弹出的模式窗口<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;window.dialogArguments.location.reload();&nbsp;<br /><br /><br />&nbsp;&nbsp;&nbsp;<br />3.javascript弹出窗口代码&nbsp;<br />&nbsp;&nbsp;&nbsp;下面给两个弹出屏幕居中窗口的例子<br />&nbsp;&nbsp;&nbsp;window.open()方式<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;ShowDialog(url)&nbsp;{&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;iWidth=300;&nbsp;//窗口宽度<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;iHeight=200;//窗口高度<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;iTop=(window.screen.height-iHeight)/2;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;iLeft=(window.screen.width-iWidth)/2;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;window.open(url,&quot;Detail&quot;,&quot;Scrollbars=no,Toolbar=no,Location=no,Direction=no,Resizeable=no,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Width=&quot;+iWidth+&quot;&nbsp;,Height=&quot;+iHeight+&quot;,top=&quot;+iTop+&quot;,left=&quot;+iLeft);&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;window.showModalDialog方式<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;ShowDialog(url)&nbsp;{&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;iWidth=300;&nbsp;//窗口宽度<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;iHeight=200;//窗口高度<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;iTop=(window.screen.height-iHeight)/2;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;iLeft=(window.screen.width-iWidth)/2;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;window.showModalDialog(url,window,&quot;dialogHeight:&nbsp;&quot;+iHeight+&quot;px;&nbsp;dialogWidth:&nbsp;&quot;+iWidth+&quot;px;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dialogTop:&nbsp;&quot;+iTop+&quot;;&nbsp;dialogLeft:&nbsp;&quot;+iLeft+&quot;;&nbsp;resizable:&nbsp;no;&nbsp;status:&nbsp;no;scroll:no&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注意这里的第二个参数，window<br /><br /><br />4.模式窗口数据不刷新（缓存）问题<br /><br />在jsp页面加入如下语句&nbsp;&nbsp;<br /><br />&lt;%<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.setHeader(&quot;Pragma&quot;,&quot;No-Cache&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.setHeader(&quot;Cache-Control&quot;,&quot;No-Cache&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.setDateHeader(&quot;Expires&quot;,&nbsp;0);<br />%&gt;<br /><br />5,模式窗口中，链接弹出新窗口问题<br /><br />&nbsp;在&lt;/head&gt;和&lt;body&gt;间加入&lt;base&nbsp;target=&quot;_self&quot;&gt;<br /><br />6.无提示关闭页面的方法<br />function&nbsp;CloseWin(){&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;ua&nbsp;=&nbsp;navigator.userAgent;&nbsp;var&nbsp;ie&nbsp;=&nbsp;navigator.appName==&quot;Microsoft&nbsp;Internet&nbsp;Explorer&quot;?true:false;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;if(ie){<br />&nbsp;var&nbsp;IEversion&nbsp;=&nbsp;parseFloat(ua.substring(ua.indexOf(&quot;MSIE&nbsp;&quot;)+5,ua.indexOf(&quot;;&quot;,ua.indexOf(&quot;MSIE&nbsp;&quot;))));&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;IEversion&lt;&nbsp;5.5){<br />&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;str&nbsp;=&nbsp;'';<br />&nbsp;&nbsp;&nbsp;&nbsp;document.body.insertAdjacentHTML(&quot;beforeEnd&quot;,&nbsp;str);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all.noTipClose.Click();&nbsp;<br />&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;window.opener&nbsp;=null;&nbsp;window.close();<br />&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;}else{&nbsp;<br />&nbsp;&nbsp;window.close()&nbsp;<br />&nbsp;&nbsp;}<br />&nbsp; }]]></description><category>asp</category><comments>http://blog.cnxcn.net/post/186.html#comment</comments><wfw:comment>http://blog.cnxcn.net/</wfw:comment><wfw:commentRss>http://blog.cnxcn.net/feed.asp?cmt=186</wfw:commentRss><trackback:ping>http://blog.cnxcn.net/cmd.asp?act=tb&amp;id=186&amp;key=b9550d24</trackback:ping></item><item><title>ASP中过滤SQL字符</title><author>peijialai@qingdaotse.com (文心春萌)</author><link>http://blog.cnxcn.net/post/185.html</link><pubDate>Wed, 13 Jun 2007 15:40:52 +0800</pubDate><guid>http://blog.cnxcn.net/post/185.html</guid><description><![CDATA[主要代码如下：<br /><br />function&nbsp;POP_sqlin(text)&nbsp;&nbsp;<br />&nbsp;&nbsp;if&nbsp;isnull(text)&nbsp;then<br />&nbsp;&nbsp;&nbsp;&nbsp;POP_sqlin=&quot;&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;exit&nbsp;function<br />&nbsp;&nbsp;end&nbsp;if<br /><br />&nbsp;&nbsp;dim&nbsp;Sqlwords<br />&nbsp;&nbsp;Set&nbsp;Sqlwords=new&nbsp;RegExp<br />&nbsp;&nbsp;Sqlwords.IgnoreCase&nbsp;=True<br />&nbsp;&nbsp;Sqlwords.Global=True<br /><br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(')&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;''&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(;)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;；&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(%)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;％&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(and)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ａｎｄ&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(exec)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ｅｘｅｃ&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(execute)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ｅｘｅｃｕｔｅ&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(insert)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ｉｎｓｅｒｔ&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(select)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ｓｅｌｅｃｔ&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(delete)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ｄｅｌｅｔｅ&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(update)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ｕｐｄａｔｅ&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(count)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ｃｏｕｎｔ&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(chr)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ｃｈｒ&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(mid)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ｍｉｄ&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(master)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ｍａｓｔｅｒ&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(truncate)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ｔｒｕｎｃａｔｅ&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(char)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ｃｈａｒ&quot;)<br />&nbsp;&nbsp;Sqlwords.Pattern=&quot;(declare)&quot;<br />&nbsp;&nbsp;text=Sqlwords.Replace(text,&quot;ｄｅｃｌａｒｅ&quot;)<br /><br />&nbsp;&nbsp;Set&nbsp;Sqlwords=Nothing<br />&nbsp;&nbsp;POP_sqlin&nbsp;=&nbsp;text<br />end&nbsp;function<br /><br />function&nbsp;POP_sqlout(text)&nbsp;&nbsp;<br />&nbsp;&nbsp;if&nbsp;isnull(text)&nbsp;then<br />&nbsp;&nbsp;&nbsp;&nbsp;POP_sqlout=&quot;&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;exit&nbsp;function<br />&nbsp;&nbsp;end&nbsp;if<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;''&quot;,&quot;'&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;；&quot;,&quot;;&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;％&quot;,&quot;%&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ａｎｄ&quot;,&quot;and&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ｅｘｅｃ&quot;,&quot;exec&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ｅｘｅｃｕｔｅ&quot;,&quot;execute&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ｉｎｓｅｒｔ&quot;,&quot;insert&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ｓｅｌｅｃｔ&quot;,&quot;select&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ｄｅｌｅｔｅ&quot;,&quot;delete&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ｕｐｄａｔｅ&quot;,&quot;update&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ｃｏｕｎｔ&quot;,&quot;count&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ｃｈｒ&quot;,&quot;chr&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ｍｉｄ&quot;,&quot;mid&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ｍａｓｔｅｒ&quot;,&quot;master&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ｔｒｕｎｃａｔｅ&quot;,&quot;truncate&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ｃｈａｒ&quot;,&quot;char&quot;)<br />&nbsp;&nbsp;text&nbsp;=&nbsp;Replace(text,&quot;ｄｅｃｌａｒｅ&quot;,&quot;declare&quot;)<br />&nbsp;&nbsp;POP_sqlout&nbsp;=&nbsp;text<br />end&nbsp;function<br /><br />function&nbsp;HTMLEncode(popstring)<br />&nbsp;&nbsp;if&nbsp;not&nbsp;isnull(popstring)&nbsp;then<br />&nbsp;&nbsp;popstring&nbsp;=&nbsp;POP_sqlout(popstring)<br />&nbsp;&nbsp;popstring&nbsp;=&nbsp;replace(popstring,&nbsp;&quot;&gt;&quot;,&nbsp;&quot;&gt;&quot;)<br />&nbsp;&nbsp;popstring&nbsp;=&nbsp;replace(popstring,&nbsp;&quot;&lt;&quot;,&nbsp;&quot;&lt;&quot;)<br />&nbsp;&nbsp;popstring&nbsp;=&nbsp;Replace(popstring,&nbsp;CHR(32),&nbsp;&quot;&nbsp;&quot;)<br />&nbsp;&nbsp;popstring&nbsp;=&nbsp;Replace(popstring,&nbsp;CHR(9),&nbsp;&quot;&nbsp;&quot;)<br />&nbsp;&nbsp;popstring&nbsp;=&nbsp;Replace(popstring,&nbsp;CHR(34),&nbsp;&quot;&quot;&quot;&quot;)<br />&nbsp;&nbsp;popstring&nbsp;=&nbsp;Replace(popstring,&nbsp;CHR(39),&nbsp;&quot;'&quot;)<br />&nbsp;&nbsp;popstring&nbsp;=&nbsp;Replace(popstring,&nbsp;CHR(10)&nbsp;&amp;&nbsp;CHR(10),&nbsp;&quot;&lt;/p&gt;&lt;p&gt;&nbsp;&quot;)<br />&nbsp;&nbsp;popstring&nbsp;=&nbsp;Replace(popstring,&nbsp;CHR(10),&nbsp;&quot;&lt;br&nbsp;/&gt;&nbsp;&quot;)<br />&nbsp;&nbsp;popstring&nbsp;=&nbsp;Replace(popstring,&nbsp;CHR(36),&nbsp;&quot;$&quot;)<br />&nbsp;&nbsp;HTMLEncode&nbsp;=&nbsp;popstring<br />&nbsp;&nbsp;end&nbsp;if<br />end&nbsp;function<br /><br /><br /><br />使用方法：<br />把需要过滤的提交信息改为POP_sqlin(提交的信息)即可<br />在需要把信息还原时改为：Htmlencode(提交的信息)即可<br /><br />]]></description><category>asp</category><comments>http://blog.cnxcn.net/post/185.html#comment</comments><wfw:comment>http://blog.cnxcn.net/</wfw:comment><wfw:commentRss>http://blog.cnxcn.net/feed.asp?cmt=185</wfw:commentRss><trackback:ping>http://blog.cnxcn.net/cmd.asp?act=tb&amp;id=185&amp;key=9725c7a4</trackback:ping></item><item><title>ASP常用函数收藏 </title><author>peijialai@qingdaotse.com (文心春萌)</author><link>http://blog.cnxcn.net/post/184.html</link><pubDate>Wed, 13 Jun 2007 10:33:00 +0800</pubDate><guid>http://blog.cnxcn.net/post/184.html</guid><description><![CDATA[<p><span class="Caption"><strong><font color="#800000">写个函数，能防范大部分<span class="Caption">sql注入漏洞&nbsp; </span>Function SafeRequest(ParaName,ParaType)</font></strong></span><br /></p><p>Function SafeRequest(ParaName,ParaType)<br />'--- 传入参数 ---<br />'ParaName:参数名称-字符型<br />'ParaType:参数类型-数字型(1表示以上参数是数字，0表示以上参数为字符)</p><p>Dim ParaValue<br />ParaValue=Request(ParaName)<br />If ParaType=1 then<br />If not isNumeric(ParaValue) then<br />Response.write &quot;参数&quot; &amp; ParaName &amp; &quot;必须为数字型！&quot;<br />Response.end<br />End if<br />Else<br />ParaValue=replace(ParaValue,&quot;'&quot;,&quot;''&quot;)<br />End if<br />SafeRequest=ParaValue<br />End function </p><p><font color="#ff0000">=========================================================</font></p><p>&lt;%<br /><font color="#ff0000">'*******************************************************************<br />'取得IP地址<br />'*******************************************************************</font><br />Function Userip()<br />&nbsp;&nbsp;&nbsp; Dim GetClientIP<br />&nbsp;&nbsp;&nbsp; '如果客户端用了***************，则应该用ServerVariables(&quot;HTTP_X_FORWARDED_FOR&quot;)方法<br />&nbsp;&nbsp;&nbsp; GetClientIP = Request.ServerVariables(&quot;HTTP_X_FORWARDED_FOR&quot;)<br />&nbsp;&nbsp;&nbsp; If GetClientIP = &quot;&quot; or isnull(GetClientIP) or isempty(GetClientIP) Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '如果客户端没用代理，应该用Request.ServerVariables(&quot;REMOTE_ADDR&quot;)方法<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetClientIP = Request.ServerVariables(&quot;REMOTE_ADDR&quot;)<br />&nbsp;&nbsp;&nbsp; end if<br />&nbsp;&nbsp;&nbsp; Userip = GetClientIP<br />End function</p><p><font color="#ff0000">'*******************************************************************<br />' 弹出对话框<br />'*******************************************************************</font><br />Sub alert(message)<br />&nbsp; message = replace(message,&quot;'&quot;,&quot;\'&quot;)<br />&nbsp; Response.Write (&quot;&lt;script&gt;alert('&quot; &amp; message &amp; &quot;')&lt;/script&gt;&quot;)<br />End Sub<br />&nbsp;<br /><font color="#ff0000">'*******************************************************************<br />' 返回上一页，一般用在判断信息提交是否完全之后<br />'*******************************************************************</font><br />Sub GoBack()<br />&nbsp; Response.write (&quot;&lt;script&gt;history.go(-1)&lt;/script&gt;&quot;)<br />End Sub<br />&nbsp;<br /><font color="#ff0000">'*******************************************************************<br />' 重定向另外的连接<br />'*******************************************************************</font><br />Sub Go(url)<br />&nbsp; Response.write (&quot;&lt;script&gt;location.href('&quot; &amp; url &amp; &quot;')&lt;/script&gt;&quot;)<br />End Sub</p><p><font color="#ff0000">'*******************************************************************<br />' 指定秒数重定向另外的连接<br />'*******************************************************************<br /></font>sub GoPage(url,s)<br />&nbsp; s=s*1000<br />&nbsp; Response.Write &quot;&lt;SCRIPT LANGUAGE=JavaScript&gt;&quot;<br />&nbsp; Response.Write &quot;window.setTimeout(&quot;&amp;chr(34)&amp;&quot;window.navigate('&quot;&amp;url&amp;&quot;')&quot;&amp;chr(34)&amp;&quot;,&quot;&amp;s&amp;&quot;)&quot;<br />&nbsp; Response.Write &quot;&lt;/script&gt;&quot;<br />end sub</p><p><font color="#ff0000">'*******************************************************************<br />' 判断数字是否整形<br />'*******************************************************************</font><br />function isInteger(para)<br />on error resume next<br />dim str<br />dim l,i<br />if isNUll(para) then <br />isInteger=false<br />exit function<br />end if<br />str=cstr(para)<br />if trim(str)=&quot;&quot; then<br />isInteger=false<br />exit function<br />end if<br />l=len(str)<br />for i=1 to l<br />if mid(str,i,1)&gt;&quot;9&quot; or mid(str,i,1)&lt;&quot;0&quot; then<br />isInteger=false <br />exit function<br />end if<br />next<br />isInteger=true<br />if err.number&lt;&gt;0 then err.clear<br />end function</p><p><font color="#ff0000">'*******************************************************************<br />' 获得文件扩展名<br />'*******************************************************************</font><br />function GetExtend(filename)<br />dim tmp<br />if filename&lt;&gt;&quot;&quot; then<br />tmp=mid(filename,instrrev(filename,&quot;.&quot;)+1,len(filename)-instrrev(filename,&quot;.&quot;))<br />tmp=LCase(tmp)<br />if instr(1,tmp,&quot;asp&quot;)&gt;0 or instr(1,tmp,&quot;php&quot;)&gt;0 or instr(1,tmp,&quot;php3&quot;)&gt;0 or instr(1,tmp,&quot;aspx&quot;)&gt;0 then<br />getextend=&quot;txt&quot;<br />else<br />getextend=tmp<br />end if<br />else<br />getextend=&quot;&quot;<br />end if<br />end function</p><p><font color="#ff0000">' *----------------------------------------------------------------------------<br />' * 函数：CheckIn<br />' * 描述：检测参数是否有SQL危险字符<br />' * 参数：str要检测的数据<br />' * 返回：FALSE：安全 TRUE：不安全<br />' * 作者：<br />' * 日期：<br />' *----------------------------------------------------------------------------</font><br />function CheckIn(str)<br />if instr(1,str,chr(39))&gt;0 or instr(1,str,chr(34))&gt;0 or instr(1,str,chr(59))&gt;0 then<br />CheckIn=true<br />else<br />CheckIn=false<br />end if<br />end function</p><p><font color="#ff0000">' *----------------------------------------------------------------------------<br />' * 函数：HTMLEncode<br />' * 描述：过滤HTML代码<br />' * 参数：--<br />' * 返回：--<br />' * 作者：<br />' * 日期：<br />' *----------------------------------------------------------------------------</font><br />function HTMLEncode(fString)<br />if not isnull(fString) then<br />fString = replace(fString, &quot;&gt;&quot;, &quot;&amp;gt;&quot;)<br />fString = replace(fString, &quot;&lt;&quot;, &quot;&amp;lt;&quot;)</p><p>fString = Replace(fString, CHR(32), &quot;&amp;nbsp;&quot;)<br />fString = Replace(fString, CHR(9), &quot;&amp;nbsp;&quot;)<br />fString = Replace(fString, CHR(34), &quot;&amp;quot;&quot;)<br />fString = Replace(fString, CHR(39), &quot;&amp;#39;&quot;)<br />fString = Replace(fString, CHR(13), &quot;&quot;)<br />fString = Replace(fString, CHR(10) &amp; CHR(10), &quot;&lt;/P&gt;&lt;P&gt; &quot;)<br />fString = Replace(fString, CHR(10), &quot;&lt;BR&gt; &quot;)</p><p>HTMLEncode = fString<br />end if<br />end function</p><p><font color="#ff0000">' *----------------------------------------------------------------------------<br />' * 函数：HTMLcode<br />' * 描述：过滤表单字符<br />' * 参数：--<br />' * 返回：--<br />' * 作者：<br />' * 日期：<br />' *----------------------------------------------------------------------------</font><br />function HTMLcode(fString)<br />if not isnull(fString) then<br />fString = Replace(fString, CHR(13), &quot;&quot;)<br />fString = Replace(fString, CHR(10) &amp; CHR(10), &quot;&lt;/P&gt;&lt;P&gt;&quot;)<br />fString = Replace(fString, CHR(34), &quot;&quot;)<br />fString = Replace(fString, CHR(10), &quot;&lt;BR&gt;&quot;)<br />HTMLcode = fString<br />end if<br />end function</p><p><font color="#ff0000">' *----------------------------------------------------------------------------<br />' * 函数：HTMLREM<br />' * 描述：解决过滤<br />' * 参数：--<br />' * 返回：--<br />' * 作者：<br />' * 日期：<br />' *----------------------------------------------------------------------------</font><br />function HTMLREM(fString)<br />if not isnull(fString) then<br />fString = Replace(fString, CHR(13), &quot;&quot;)<br />fString = Replace(fString, CHR(10) &amp; CHR(10), &quot;&quot;)<br />fString = Replace(fString, CHR(10), &quot;&quot;)<br />fString=ReplaceSpace(fString)<br />fString=HTMLEncode(fString)<br />HTMLREM = fString<br />end if<br />end function</p><p><font color="#ff0000">' *----------------------------------------------------------------------------<br />' * 函数：ReplaceSpace<br />' * 描述：替换所有相连空格为单空格<br />' * 参数：--<br />' * 返回：--<br />' * 作者：<br />' * 日期：<br />' *----------------------------------------------------------------------------</font><br />function ReplaceSpace(content)<br />content=trim(content)<br />if content=&quot;&quot; then<br />replacespace=&quot;&quot;<br />else<br />while not instr(1,content,&quot; &quot;)=0<br />content=Replace(content,&quot; &quot;,&quot; &quot;)<br />wend<br />replacespace=content<br />end if<br />end function</p><p>rem 将字串处理成sql中语句的一部分之搜索条件</p><p>function StrToSql_or(content,field)<br />content=trim(content)<br />if content=&quot;&quot; then<br />strtosql_or=&quot;&quot;<br />else<br />' and <br />strtosql_or=field &amp; &quot; like '%&quot; &amp; replace(content,&quot; &quot;,&quot;%' or &quot; &amp; field &amp; &quot; like '%&quot;) &amp; &quot;%'&quot;<br />end if<br />end function</p><p>rem 将字串处理成sql中语句的一部分之搜索日期<br />function StrToSql_Date(searchdate,field)<br />searchdate=clng(searchdate)<br />select case searchdate<br />case 0<br />StrToSql_Date=&quot;&quot;<br />case 1<br />StrToSql_Date=field &amp; &quot; between '&quot; &amp; dateadd(&quot;ww&quot;,-1,date()) &amp; &quot;' and '&quot; &amp; date() &amp; &quot;'&quot;<br />case 2<br />StrToSql_Date=field &amp; &quot; between '&quot; &amp; dateadd(&quot;m&quot;,-1,date()) &amp; &quot;' and '&quot; &amp; date() &amp; &quot;'&quot;<br />case 3<br />StrToSql_Date=field &amp; &quot; between '&quot; &amp; dateadd(&quot;q&quot;,-1,date()) &amp; &quot;' and '&quot; &amp; date() &amp; &quot;'&quot;<br />case 4<br />StrToSql_Date=field &amp; &quot; between '&quot; &amp; dateadd(&quot;yyyy&quot;,-1,date()) &amp; &quot;' and '&quot; &amp; date() &amp; &quot;'&quot;<br />end select<br />end function</p><p>function StrToSql_Date2(field)<br />dim date_Previous,date_next<br />date_previous=dateadd(&quot;d&quot;,-(Weekday(date(),2)-1),(date() &amp; &quot; 1:00:00&quot;))<br />date_next=dateadd(&quot;d&quot;,(7-Weekday(date(),2)),(date() &amp; &quot; 23:59:59&quot;))<br />StrToSql_Date2=field &amp; &quot; between '&quot; &amp; date_previous &amp; &quot;' and '&quot; &amp; date_next &amp; &quot;'&quot;<br />end function</p><p>rem 字符截断<br />function Strfix(content,n)<br />content=trim(content)<br />if len(content)&gt;n then<br />Strfix=left(content,n) &amp; &quot;...&quot;<br />else<br />Strfix=content<br />end if<br />end function</p><p>rem 字符串处理－截断（新闻）<br />function StrNewfix(content)<br />content=trim(content)<br />if len(content)&gt;27 then<br />strnewfix=left(content,27) &amp; &quot;...&quot;<br />else<br />strnewfix=content<br />end if<br />end function<br />%&gt;</p><p><br />==========================================================</p><pre>'@转换日期为星期几函数<br />'@idate为标准日期格式<br />'@itype为0时表示英文星期几,否则为中文<br />function showweek(idate,itype)<br />if itype &lt;&gt; 0 then itype = 1&nbsp;'//防止误输出错<br />dim inum,nday<br />inum = weekday(idate)<br />if itype = 0 then<br />&nbsp;select case inum<br />&nbsp;&nbsp;case 1<br />&nbsp;&nbsp;&nbsp;nday = &quot;Sunday&quot;<br />&nbsp;&nbsp;case 2<br />&nbsp;&nbsp;&nbsp;nday = &quot;Monday&quot;<br />&nbsp;&nbsp;case 3<br />&nbsp;&nbsp;&nbsp;nday = &quot;Tuesday&quot;<br />&nbsp;&nbsp;case 4<br />&nbsp;&nbsp;&nbsp;nday = &quot;Wednesday&quot;<br />&nbsp;&nbsp;case 5<br />&nbsp;&nbsp;&nbsp;nday = &quot;Thursday&quot;<br />&nbsp;&nbsp;case 6<br />&nbsp;&nbsp;&nbsp;nday = &quot;Friday&quot;<br />&nbsp;&nbsp;case 7<br />&nbsp;&nbsp;&nbsp;nday = &quot;Saturday&quot;<br />&nbsp;end select<br />else<br />&nbsp;select case inum<br />&nbsp;&nbsp;case 1<br />&nbsp;&nbsp;&nbsp;nday = &quot;星期天&quot;<br />&nbsp;&nbsp;case 2<br />&nbsp;&nbsp;&nbsp;nday = &quot;星期一&quot;<br />&nbsp;&nbsp;case 3<br />&nbsp;&nbsp;&nbsp;nday = &quot;星期二&quot;<br />&nbsp;&nbsp;case 4<br />&nbsp;&nbsp;&nbsp;nday = &quot;星期三&quot;<br />&nbsp;&nbsp;case 5<br />&nbsp;&nbsp;&nbsp;nday = &quot;星期四&quot;<br />&nbsp;&nbsp;case 6<br />&nbsp;&nbsp;&nbsp;nday = &quot;星期五&quot;<br />&nbsp;&nbsp;case 7<br />&nbsp;&nbsp;&nbsp;nday = &quot;星期六&quot;<br />&nbsp;end select<br />end if<br />'//OUTPUT<br />&nbsp;showweek = nday<br />end function<br />'//*************************************************************</pre><pre>'@分页列表函数<br />'@参数说明：TotalReCount:记录总数<br />'@page:当前页码,pagesize:分页大小，url:页面地址<br />function PageList(TotalReCount,page,pagesize,url)<br />dim startPage,endPage,ipage,totalPage<br />'//判断链接文件后参数个数<br />if inStr(1,url,&quot;?&quot;) = 0 then<br />&nbsp;url = url &amp; &quot;?&quot;<br />else<br />&nbsp;url = url &amp; &quot;&amp;amp;&quot;<br />end if<br />'//得到总页数<br />totalPage = TotalReCount \ pagesize<br />if TotalRecount mod pagesize &lt;&gt; 0 then totalPage = Cint(TotalRecount\pagesize+1)<br />startPage = 1<br />endPage = totalPage<br />if page &gt; 10 then startPage = page - 4<br />if totalPage &lt; 10 then<br />&nbsp;endPage = totalPage<br />else<br />&nbsp;if page =&lt; 10 then<br />&nbsp;&nbsp;endPage = 10<br />&nbsp;else<br />&nbsp;&nbsp;endPage = page + 4<br />&nbsp;&nbsp;if endPage &gt; totalPage then endPage = totalPage<br />&nbsp;end if<br />end if%&gt;<br />共有:&lt;%=TotalReCount%&gt;&amp;nbsp;&lt;%=pagesize%&gt;页 <br />&lt;%if page&gt;1 then%&gt;<br />&lt;a href=&quot;&lt;%=url%&gt;page=1&quot;&gt;&lt;font face=&quot;webdings&quot;&gt;9&lt;/font&gt;&lt;/a&gt;&amp;nbsp;<br />&lt;a href=&quot;&lt;%=url%&gt;page=&lt;%=page-1%&gt;&quot;&gt;&lt;font face=&quot;webdings&quot;&gt;7&lt;/font&gt;&lt;/a&gt;&amp;nbsp;<br />&lt;%end if%&gt;<br />&lt;%for ipage = startPage to endPage<br />if ipage &lt;&gt; page then%&gt;<br />&nbsp;&lt;a href=&quot;&quot;&gt;&lt;%=ipage%&gt;&lt;/a&gt;&amp;nbsp;<br />&lt;%else<br />&nbsp;response.write i&amp;&quot;&amp;nbsp;&quot;<br />end if<br />next%&gt;<br />&lt;%if (totalPage-page)&gt;4 then%&gt;<br />&lt;a href=&quot;&lt;%=url%&gt;page=&lt;%=page+1%&gt;&quot;&gt;&lt;font face=&quot;webdings&quot;&gt;8&lt;/font&gt;&lt;/a&gt;&amp;nbsp;<br />&lt;a href=&quot;&lt;%=url%&gt;page=&lt;%=totalPage%&gt;&quot;&gt;&lt;font face=&quot;webdings&quot;&gt;:&lt;/font&gt;&lt;/a&gt;&amp;nbsp;<br />&lt;%end if</pre><pre>end function<br />'//*************************************************************</pre><pre><br />'//检测组件是否安装函数<br />Function IsObjInstalled(strClassString)<br />On Error Resume Next<br />&nbsp;IsObjInstalled = False<br />&nbsp;Err = 0<br />&nbsp;Dim xTestObj<br />&nbsp;Set xTestObj = Server.CreateObject(strClassString)<br />&nbsp;If 0 = Err Then IsObjInstalled = True<br />&nbsp;Set xTestObj = Nothing<br />&nbsp;Err = 0<br />End Function<br />'//*************************************************************</pre><pre>Function SafeRequest(ParaName,ParaType)&nbsp;&nbsp;&nbsp;'防止SQL注入攻击代码<br />'--- 传入参数 ---//例: SafeRequest(&quot;username&quot;,0)或SafeRequest(&quot;id&quot;,1)<br />'ParaName:参数名称-字符型<br />'ParaType:参数类型-数字型(1表示参数是数字，0表示参数为字符)</pre><pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ParaValue<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ParaValue=Request(ParaName)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If ParaType=1 then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If not isNumeric(ParaValue) then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Response.write &quot;&lt;script language=javascript&gt;alert('参数&quot; &amp; ParaName &amp; &quot;必须为数字型！');&lt;/script&gt;&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.write &quot;&lt;script language=javascript&gt;window.history.back();&lt;/script&gt;&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.end<br />&nbsp;&nbsp;&nbsp;&nbsp; elseif ParaValue &lt; 1 then<br />&nbsp;&nbsp;&nbsp;&nbsp; ParaValue = 1<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End if<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ParaValue=replace(ParaValue,&quot;'&quot;,&quot;''&quot;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End if<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SafeRequest=ParaValue<br />End function<br />'//*************************************************************</pre><pre>'//HTML解码函数<br />Function HTMLDecode(fString)<br />&nbsp;If Not IsNull(fString) Then<br />&nbsp;&nbsp;fString = replace(fString, &quot;&amp;gt;&quot;, &quot;&gt;&quot;)<br />&nbsp;&nbsp;fString = replace(fString, &quot;&amp;lt;&quot;, &quot;&lt;&quot;)<br />&nbsp;&nbsp;fString = Replace(fString, &quot; &quot;, CHR(32))&nbsp;&nbsp;'&amp;nbsp;<br />&nbsp;&nbsp;fString = Replace(fString, &quot; &quot;, CHR(9))&nbsp;&nbsp;&nbsp;'&amp;nbsp;<br />&nbsp;&nbsp;fString = Replace(fString, &quot;&amp;quot;&quot;, CHR(34))&nbsp;'双引号过滤<br />&nbsp;&nbsp;'fString = Replace(fString, CHR(39), &quot;&amp;#39;&quot;)&nbsp;'单引号过滤<br />&nbsp;&nbsp;'fString = Replace(fString, ,&quot;&quot; CHR(13))<br />&nbsp;&nbsp;fString = Replace(fString, &quot;&lt;/p&gt;&lt;p&gt;&quot;, CHR(10) &amp; CHR(10))<br />&nbsp;&nbsp;fString = Replace(fString, &quot;&lt;br&gt;&quot;, CHR(10))<br />&nbsp;&nbsp;HTMLDecode = fString<br />&nbsp;End If<br />End Function<br />'//*************************************************************</pre><pre>'//HTML编码函数<br />Function HTMLEncode(fString)<br />&nbsp;If Not IsNull(fString) Then<br />&nbsp;&nbsp;fString = replace(fString, &quot;&gt;&quot;, &quot;&amp;gt;&quot;)<br />&nbsp;&nbsp;fString = replace(fString, &quot;&lt;&quot;, &quot;&amp;lt;&quot;)<br />&nbsp;&nbsp;fString = Replace(fString, CHR(32), &quot; &quot;)&nbsp;&nbsp;'&amp;nbsp;<br />&nbsp;&nbsp;fString = Replace(fString, CHR(9), &quot; &quot;)&nbsp;&nbsp;&nbsp;'&amp;nbsp;<br />&nbsp;&nbsp;fString = Replace(fString, CHR(34), &quot;&amp;quot;&quot;)&nbsp;'双引号过滤<br />&nbsp;&nbsp;'fString = Replace(fString, CHR(39), &quot;&amp;#39;&quot;)&nbsp;'单引号过滤<br />&nbsp;&nbsp;fString = Replace(fString, CHR(13), &quot;&quot;)<br />&nbsp;&nbsp;fString = Replace(fString, CHR(10) &amp; CHR(10), &quot;&lt;/p&gt;&lt;p&gt;&quot;)<br />&nbsp;&nbsp;fString = Replace(fString, CHR(10), &quot;&lt;br&gt;&quot;)<br />&nbsp;&nbsp;HTMLEncode = fString<br />&nbsp;End If<br />End Function<br />'//*************************************************************</pre><pre>'CFS Encode Function<br />Function CfsEnCode(CodeStr)<br />Dim CodeLen<br />Dim CodeSpace<br />Dim NewCode<br />dim cecr,cecb,cec<br />CodeLen = 30<br />CodeSpace = CodeLen - Len(CodeStr)<br />If Not CodeSpace &lt; 1 Then<br />&nbsp;For cecr = 1 To CodeSpace<br />&nbsp;&nbsp;CodeStr = CodeStr &amp; Chr(21)<br />&nbsp;Next<br />End If<br />NewCode = 1<br />Dim Been<br />For cecb = 1 To CodeLen<br />&nbsp;Been = CodeLen + Asc(Mid(CodeStr,cecb,1)) * cecb<br />&nbsp;NewCode = NewCode * Been<br />Next<br />CodeStr = NewCode<br />NewCode = Empty<br />For cec = 1 To Len(CodeStr)<br />&nbsp;NewCode = NewCode &amp; CfsCode(Mid(CodeStr,cec,3))<br />Next<br />For cec = 20 To Len(NewCode) - 18 Step 2<br />&nbsp;CfsEnCode = CfsEnCode &amp; Mid(NewCode,cec,1)<br />Next<br />End Function</pre><pre>Function CfsCode(Word)<br />dim cc<br />For cc = 1 To Len(Word)<br />&nbsp;CfsCode = CfsCode &amp; Asc(Mid(Word,cc,1))<br />Next<br />CfsCode = Hex(CfsCode)<br />End Function<br />'//*************************************************************</pre><pre>'//转换中文货币大小写<br />function CLMoney(thenumber) <br />dim Money,i,String1,String2,length,checkp'定义变量 <br />dim one(),onestr()'定义数组 </pre><pre>String1 = &quot;零壹贰叁肆伍陆柒捌玖&quot; <br />String2 = &quot;万仟佰拾亿仟佰拾万仟佰拾元角分厘毫&quot; </pre><pre>checkp=instr(thenumber,&quot;.&quot;)'判断是否含有小数位 <br />if checkp&lt;&gt;0 then <br />thenumber=replace(thenumber,&quot;.&quot;,&quot;&quot;)'去除小数位 <br />end if </pre><pre>length=len(thenumber) '取得数据长度 <br />redim one(length-1)'重新定义数组大小 <br />redim onestr(length-1)'重新定义数组大小 </pre><pre>for i=0 to length-1 </pre><pre>one(i)=mid(thenumber,i+1,1) '循环取得每一位的数字 <br />one(i)=mid(string1,one(i)+1,1)'循环取得数字对应的大写 </pre><pre><br />if checkp=0 then <br />'不含有小数的数据其数字对应的单位 <br />onestr(i)=mid(string2,14-length+i,1) <br />else <br />'含有小数的数据其数字对应的单位 <br />onestr(i)=mid(string2,15-length+i+len(thenumber)-checkp,1) <br />end if </pre><pre>one(i)=one(i)&amp;onestr(i)'将数字与单位组合 <br />next </pre><pre>Money=replace(join(one),&quot; &quot;,&quot;&quot;) '取得数组中所有的元素，并连接起来 <br />Money=replace(Money,&quot;零元&quot;,&quot;元&quot;) <br />Money=replace(Money,&quot;零万&quot;,&quot;万&quot;) <br />Money=replace(Money,&quot;零亿&quot;,&quot;亿&quot;) <br />Money=replace(Money,&quot;零仟&quot;,&quot;零&quot;) <br />Money=replace(Money,&quot;零佰&quot;,&quot;零&quot;) <br />Money=replace(Money,&quot;零拾&quot;,&quot;零&quot;) </pre><pre>do while not instr(Money,&quot;零零&quot;)=0 <br />Money=replace(Money,&quot;零零&quot;,&quot;零&quot;) <br />loop <br />CLmoney = Money<br />end function<br />'//***********************************************************</pre><pre>'//IP转换成数字，限制IP时用<br />'@使用示例<br />'//&nbsp;userIPnum = IP2Num(Request.ServerVariables(&quot;REMOTE_ADDR&quot;))<br />'//&nbsp;if userIPnum &gt; IP2Num(&quot;192.168.0.0&quot;) and userIPnum &lt; <br />'//&nbsp;IP2Num(&quot;192.168.0.255&quot;) then<br />'//&nbsp;&nbsp;response.write (&quot;&lt;center&gt;您的IP被禁止&lt;/center&gt;&quot;)<br />'//&nbsp;&nbsp;response.end<br />'//&nbsp;end if</pre><pre>function IP2Num(sip)<br />&nbsp;dim str1,str2,str3,str4<br />&nbsp;dim num<br />&nbsp;IP2Num=0<br />&nbsp;if isnumeric(left(sip,2)) then<br />&nbsp;&nbsp;str1=left(sip,instr(sip,&quot;.&quot;)-1)<br />&nbsp;&nbsp;sip=mid(sip,instr(sip,&quot;.&quot;)+1)<br />&nbsp;&nbsp;str2=left(sip,instr(sip,&quot;.&quot;)-1)<br />&nbsp;&nbsp;sip=mid(sip,instr(sip,&quot;.&quot;)+1)<br />&nbsp;&nbsp;str3=left(sip,instr(sip,&quot;.&quot;)-1)<br />&nbsp;&nbsp;str4=mid(sip,instr(sip,&quot;.&quot;)+1)<br />&nbsp;&nbsp;num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1<br />&nbsp;&nbsp;IP2Num = num<br />&nbsp;end if<br />end function<br />'//********************************************************</pre><pre>==================================================================</pre><pre><p>今天在逛论坛时发现很多人都在问有关在textarea中输入的回车在html中不能显示的问题，可能这些朋友还不知道在文本中和html中显示回车的方式是不同的，因此我找了以下两个函数供大家参考：</p><p>1.HTMLEncode函数：除了server.htmlencode的所有功能以外，还有转化回车和空格的功能，可以将textarea中输入的文本按照原样在html中显示</p><p>代码如下：</p><p>function HTMLEncode(fString)<br />fString = replace(fString, &quot;&gt;&quot;, &quot;&amp;gt;&quot;)<br />fString = replace(fString, &quot;&lt;&quot;, &quot;&amp;lt;&quot;)<br />fString = Replace(fString, CHR(32), &quot;&amp;nbsp;&quot;)<br />fString = Replace(fString, CHR(34), &quot;&amp;quot;&quot;)<br />fString = Replace(fString, CHR(39), &quot;&amp;#39;&quot;)<br />fString = Replace(fString, CHR(13), &quot;&quot;)<br />fString = Replace(fString, CHR(10) &amp; CHR(10), &quot;&lt;/P&gt;&lt;P&gt;&quot;)<br />fString = Replace(fString, CHR(10), &quot;&lt;BR&gt;&quot;)<br />HTMLEncode = fString<br />end function</p><p><br />2.HTMLDecode函数：就是HTMLEncode函数的反函数，将html中的字符按照原样在textarea中显示，在修改信息时很有用</p><p>代码如下：</p><p>function HTMLDecode(fString)<br />fString = replace(fString, &quot;&amp;gt;&quot;, &quot;&gt;&quot;)<br />fString = replace(fString, &quot;&amp;lt;&quot;, &quot;&lt;&quot;)<br />fString = Replace(fString,&quot;&amp;nbsp;&quot;,chr(32))<br />fString = Replace(fString,&quot;&amp;quot;&quot;,chr(34))<br />fString = Replace(fString,&quot;&amp;#39;&quot;,chr(39))<br />fString = Replace(fString, &quot;&quot;, CHR(13))<br />fString = Replace(fString, &quot;&lt;/P&gt;&lt;P&gt;&quot;, CHR(10) &amp; CHR(10))<br />fString = Replace(fString, &quot;&lt;BR&gt;&quot;, CHR(10))<br />HTMLDecode = fString<br />end function</p><p>&nbsp;<br />=======================================================================、</p><p>&nbsp;</p><p><strong><font color="#800000">提交字符串替换</font></strong></p><p><strong><font color="#800000">把换行符和空格替换一下，函数</font></strong></p><p><strong><font color="#800000"></font></strong></p><p>function HTMLEncode(fString)<br />if not isnull(fString) then<br />&nbsp;&nbsp;&nbsp; fString = replace(fString, &quot;&gt;&quot;, &quot;&amp;gt;&quot;)<br />&nbsp;&nbsp;&nbsp; fString = replace(fString, &quot;&lt;&quot;, &quot;&amp;lt;&quot;)</p><p>&nbsp;&nbsp;&nbsp; fString = Replace(fString, CHR(32), &quot;&amp;nbsp;&quot;)<br />&nbsp;&nbsp;&nbsp; fString = Replace(fString, CHR(34), &quot;&amp;quot;&quot;)<br />&nbsp;&nbsp;&nbsp; fString = Replace(fString, CHR(39), &quot;&amp;#39;&quot;) <br />&nbsp;&nbsp;&nbsp; fString = Replace(fString, CHR(13), &quot;&quot;)<br />&nbsp;&nbsp;&nbsp; fString = Replace(fString, CHR(10) &amp; CHR(10), &quot;&lt;/P&gt;&lt;P&gt; &quot;)<br />&nbsp;&nbsp;&nbsp; fString = Replace(fString, CHR(10), &quot;&lt;BR&gt; &quot;)<br />&nbsp;&nbsp;&nbsp; HTMLEncode = fString<br />end if<br />end function </p><p>输出时只要写上HTMLEncode(rs(&quot;content&quot;))</p><p>&nbsp;</p></pre>]]></description><category>asp</category><comments>http://blog.cnxcn.net/post/184.html#comment</comments><wfw:comment>http://blog.cnxcn.net/</wfw:comment><wfw:commentRss>http://blog.cnxcn.net/feed.asp?cmt=184</wfw:commentRss><trackback:ping>http://blog.cnxcn.net/cmd.asp?act=tb&amp;id=184&amp;key=17ae590a</trackback:ping></item></channel></rss>
