<?xml version="1.0" encoding="UTF-8"?>
  <feed xmlns="http://www.w3.org/2005/Atom">
  <title type="html"><![CDATA[AS a Programer]]></title>
  <subtitle type="html"><![CDATA[Become an ActionScri&#112;t Programer]]></subtitle>
  <id>http://blog.kidbook.com.tw/asaprogramer/</id>
  <link rel="alternate" type="text/html" href="http://blog.kidbook.com.tw/asaprogramer/" /> 
  <link rel="self" type="application/atom+xml" href="http://blog.kidbook.com.tw/asaprogramer/atom.asp" /> 
  <generator uri="http://www.pjhome.net/" version="2.8">PJBlog3</generator> 
  <updated>2008-01-31T17:43:03+08:00</updated>

  <entry>
	  <title type="html"><![CDATA[同一廣告位多條廣告無刷新循環播放]]></title>
	  <author>
		 <name>FindSome</name>
		 <uri>http://blog.kidbook.com.tw/asaprogramer/</uri>
		 <email>Findsome@mail.imagery.com.tw</email>
	  </author>
	  <category term="" scheme="http://blog.kidbook.com.tw/asaprogramer/default.asp?cateID=10" label="Java&amp;Script" /> 
	  <updated>2008-01-31T17:43:03+08:00</updated>
	  <published>2008-01-31T17:43:03+08:00</published>
		  <summary type="html"><![CDATA[<p>這是一個廣告管理系統，分成 前台與後台管理兩個部份。</p>
<p>廣告的播放原理，是透過調用後台管理系統 錄入的廣告內容，然後顯示，所以我通過webservice一個方法實現根據廣告id，得到廣告代碼。</p>
<p>而多條廣告的話就需要在顯示頁面得到該廣告位應顯示的所有廣告ID列表，循環調用顯示。</p>
<p>代碼如下：</p>
<p>wevservice:</p>
<p>[WebMethod]<br />public string GetADCode(int ADID)<br />{<br />&nbsp;string ADUploadFolder=&quot;.\\&quot;+Assistant.GetConfigString(&quot;ADUploadFolder&quot;)+&quot;\\&quot;; <br />&nbsp;Advertisement.BLL.ADManage.AdContent adcontent=new Advertisement.BLL.ADManage.AdContent();<br />&nbsp;Advertisement.Model.ADManage.AdContent model=adcontent.GetModel(ADID);<br />&nbsp;if(model.ContentType==&quot;Img&quot;)//圖像類型廣告<br />&nbsp;{<br />&nbsp; string filename=ADUploadFolder+model.ImgURL;<br />&nbsp; string desc=model.ImgName;<br />&nbsp; string FileType=model.ImgType;<br />&nbsp; string LinkURL=model.LinkURL;</p>
<p>&nbsp; Advertisement.BLL.ADManage.AdPlace adplace=new Advertisement.BLL.ADManage.AdPlace();<br />&nbsp; Advertisement.Model.ADManage.AdPlace modelplace=adplace.GetModel(model.PlaceID);<br />&nbsp;&nbsp; <br />&nbsp; return Assistant.CreateTag(ADID.ToString(),filename,desc,FileType,LinkURL,modelplace.Width,modelplace.High);</p>
<p>&nbsp;}<br />&nbsp;else//嵌入代碼類型廣告<br />&nbsp;{<br />&nbsp; return model.ADCode;<br />&nbsp;}<br />}</p>
<p>顯示頁面：</p>
<p>&lt;script language=&quot;javascript&quot;&gt;<br />&nbsp;var i=0;<br />&nbsp;function chang()<br />&nbsp;{&nbsp;&nbsp;&nbsp; <br />&nbsp; if('&lt;%= IsOne%&gt;'=='false')<br />&nbsp; {<br />&nbsp;&nbsp; var strAdidlist='&lt;%=ADIDList%&gt;';//綁定廣告id列表（後台代碼得到）<br />&nbsp;&nbsp; if(strAdidlist!=&quot;&quot;)<br />&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; var arrlist=strAdidlist.split(&quot;,&quot;);<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; //循環得到每個廣告id<br />&nbsp;&nbsp;&nbsp; var adid=arrlist[i];&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; //webservice&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; docSubmit =new ActiveXObject(&quot;Microsoft.XMLDOM&quot;);<br />&nbsp;&nbsp;&nbsp; docSubmit.async = false;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; docSubmit.load(&quot;<a href="http://192.168.2.60/adweb/ADService.asmx/GetADCode?ADID=&quot;+adid">http://192.168.2.60/adweb/ADService.asmx/GetADCode?ADID=&quot;+adid</a>);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; var s=docSubmit.documentElement.text;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; //window.alert(s);<br />&nbsp;&nbsp;&nbsp; Div_AD.innerHTML=s;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; i++;<br />&nbsp;&nbsp;&nbsp; if(i==arrlist.length)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp; i=0;<br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp; }&nbsp;&nbsp; <br />&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;}<br />&nbsp;setInterval(chang,&lt;%= TimeInterval%&gt;);&nbsp;&nbsp; <br />&lt;/script&gt;</p>
<p>-----------</p>
<p>&lt;div id=&quot;Div_AD&quot;&gt;正在加載...Http://www.QQView.com&lt;/div&gt;</p>
<p>後台cs:</p>
<p>public string ADIDList=&quot;&quot;;//廣告ADID列表</p>
<p>private void Page_Load(object sender, System.EventArgs e)<br />{<br />&nbsp;if(!this.IsPostBack)<br />&nbsp;{<br />&nbsp; if((Request[&quot;PlaceID&quot;]!=null)&amp;&amp;(Request[&quot;PlaceID&quot;].ToString()!=&quot;&quot;))<br />&nbsp; {<br />&nbsp;&nbsp; string PlaceID=Request.Params[&quot;PlaceID&quot;]; <br />&nbsp;&nbsp; GetADIDList(PlaceID); //根據廣告位編碼得到該廣告位的所有廣告id列表<br />&nbsp; }<br />&nbsp;}<br />}</p>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.kidbook.com.tw/asaprogramer/article.asp?id=27" /> 
	  <id>http://blog.kidbook.com.tw/asaprogramer/default.asp?id=27</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[從JSP,ASP等動態頁面生成靜態頁面的實現方式]]></title>
	  <author>
		 <name>FindSome</name>
		 <uri>http://blog.kidbook.com.tw/asaprogramer/</uri>
		 <email>Findsome@mail.imagery.com.tw</email>
	  </author>
	  <category term="" scheme="http://blog.kidbook.com.tw/asaprogramer/default.asp?cateID=10" label="Java&amp;Script" /> 
	  <updated>2008-01-31T17:31:39+08:00</updated>
	  <published>2008-01-31T17:31:39+08:00</published>
		  <summary type="html"><![CDATA[<p>在網站應用中,為了提高頁面的訪問速度,經常需要將動態頁面靜態化以提高頁面的訪問速度,因為動態頁面一般要從數據庫檢索信息,頻繁訪問動態頁面會大大提高數據庫的負載,並且訪問速度也比靜態頁面慢.本文通過在程序裡建立一個http請求,將返回的輸出流存儲為html文件的方式來生成靜態頁面.在CMS類的應用中,信息發佈完可直接調用這段代碼,給定一個動態連接地址如<a href="http://www.QQView.com/cms/info.jsp?infoid=001">http://www.QQView.com/cms/info.jsp?infoid=001</a>,生成一個靜態頁面,代碼如下:</p>
<p>&nbsp;</p>
<p>package org.apache.easframework.common;</p>
<p>import java.io.BufferedReader;<br />import java.io.FileOutputStream;<br />import java.io.IOException;<br />import java.io.InputStreamReader;<br />import java.net.HttpURLConnection;<br />import java.net.URL;<br />import java.net.URLConnection;</p>
<p><br />/**<br />&nbsp;* 將信息發佈為靜態頁面<br />&nbsp;* @author bzwang<br />&nbsp;*<br />&nbsp;*/<br />&nbsp;<br />public class DynInfo2Html<br />{<br />&nbsp;/**<br />&nbsp; * 將信息轉化為靜態html<br />&nbsp; * @param sSourceUrl 動態信息訪問URL<br />&nbsp; * @param sDestDir&nbsp; 存儲為靜態文件的目錄<br />&nbsp; * @param sHtmlFile 生成的靜態文件名,可以按信息的唯一ID+.html命名<br />&nbsp; * @throws IOException <br />&nbsp; */<br />&nbsp;public static void convert2Html(String sSourceUrl,String sDestDir,String sHtmlFile) throws IOException<br />&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int HttpResult;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; URL url=new URL(sSourceUrl);&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; URLConnection urlconn=url.openConnection();&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; urlconn.connect();&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpURLConnection httpconn=(HttpURLConnection)urlconn;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpResult=httpconn.getResponseCode();&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(HttpResult!=HttpURLConnection.HTTP_OK)&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InputStreamReader isr =<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new InputStreamReader(httpconn.getInputStream());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BufferedReader in = new BufferedReader(isr);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String inputLine;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(!sDestDir.endsWith(&quot;/&quot;))sDestDir+=&quot;/&quot;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileOutputStream fout = new FileOutputStream(sDestDir+sHtmlFile);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while ((inputLine = in.readLine()) != null)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fout.write(inputLine.getBytes());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in.close();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fout.close();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;}<br />&nbsp;<br />&nbsp;public static void main(String[] args) throws IOException<br />&nbsp;{<br />&nbsp;&nbsp; <br />&nbsp; convert2Html(&quot;<a href="http://www.QQView.com/system/show.jsp?infoid=b3cd5cf4082a4bbebe70e332cb43fcb2&quot;,&quot;D:/projects/myproject/Src/b2c_front/Jsp/module/bzhzx/html&quot;,&quot;aaaa.html">http://www.QQView.com/system/show.jsp?infoid=b3cd5cf4082a4bbebe70e332cb43fcb2&quot;,&quot;D:/projects/myproject/Src/b2c_front/Jsp/module/bzhzx/html&quot;,&quot;aaaa.html</a>&quot;);<br />&nbsp; <br />&nbsp;}</p>
<p>}</p>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.kidbook.com.tw/asaprogramer/article.asp?id=26" /> 
	  <id>http://blog.kidbook.com.tw/asaprogramer/default.asp?id=26</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[無法以檢視/原始碼的方式觀看網頁]]></title>
	  <author>
		 <name>FindSome</name>
		 <uri>http://blog.kidbook.com.tw/asaprogramer/</uri>
		 <email>Findsome@mail.imagery.com.tw</email>
	  </author>
	  <category term="" scheme="http://blog.kidbook.com.tw/asaprogramer/default.asp?cateID=10" label="Java&amp;Script" /> 
	  <updated>2008-01-31T17:24:01+08:00</updated>
	  <published>2008-01-31T17:24:01+08:00</published>
		  <summary type="html"><![CDATA[<p>&lt;html&gt;<br />&lt;head&gt;<br />&lt;script language=&quot;javascript&quot;&gt;<br />function clear(){<br />&nbsp;&nbsp;&nbsp; Source=document.body.firstChild.data;<br />&nbsp;&nbsp;&nbsp; document.open();<br />&nbsp;&nbsp;&nbsp; document.close();<br />&nbsp;&nbsp;&nbsp; document.title=&quot;看不到源代碼&quot;;<br />&nbsp;&nbsp;&nbsp; document.body.innerHTML=Source;<br />}<br />&lt;/script&gt;<br />&lt;/head&gt;<br />&lt;body onload=clear()&gt;</p>
<p>&lt;/body&gt;<br />&lt;/html&gt;</p>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.kidbook.com.tw/asaprogramer/article.asp?id=25" /> 
	  <id>http://blog.kidbook.com.tw/asaprogramer/default.asp?id=25</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[放大縮小圖片的JavaScript ]]></title>
	  <author>
		 <name>FindSome</name>
		 <uri>http://blog.kidbook.com.tw/asaprogramer/</uri>
		 <email>Findsome@mail.imagery.com.tw</email>
	  </author>
	  <category term="" scheme="http://blog.kidbook.com.tw/asaprogramer/default.asp?cateID=10" label="Java&amp;Script" /> 
	  <updated>2008-01-31T17:12:44+08:00</updated>
	  <published>2008-01-31T17:12:44+08:00</published>
		  <summary type="html"><![CDATA[<p>&lt; img src=&quot;images/&lt; %=rs(&quot;tp_smallimg&quot;) %&gt; &quot; alt=點擊放大 border=&quot;0&quot; align=&quot;middle&quot; onload=&quot;javascript:if(this.width&gt;this.height)this.style.width=140;if(this.width&lt; =this.height) this.style.height=140;&quot;&gt;</p>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.kidbook.com.tw/asaprogramer/article.asp?id=24" /> 
	  <id>http://blog.kidbook.com.tw/asaprogramer/default.asp?id=24</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[下拉選擇頭像的Java程式]]></title>
	  <author>
		 <name>FindSome</name>
		 <uri>http://blog.kidbook.com.tw/asaprogramer/</uri>
		 <email>Findsome@mail.imagery.com.tw</email>
	  </author>
	  <category term="" scheme="http://blog.kidbook.com.tw/asaprogramer/default.asp?cateID=10" label="Java&amp;Script" /> 
	  <updated>2008-01-31T17:08:45+08:00</updated>
	  <published>2008-01-31T17:08:45+08:00</published>
		  <summary type="html"><![CDATA[<p>&lt;select name=&quot;avatarsel&quot; onchange=&quot;document.images.avatarpic.src = this[this.selectedIndex].value;&quot;&gt;<br />&lt;option value=&quot;images/clear.gif&quot;&gt; &lt;/option&gt;<br />&lt;option value='images/avatars/icone0.gif'&gt;icone0&lt;/option&gt;<br />&lt;option value='images/avatars/icone1.gif'&gt;icone1&lt;/option&gt;<br />&lt;option value='images/avatars/icone10.gif'&gt;icone10&lt;/option&gt;<br />&lt;option value='images/avatars/icone11.gif'&gt;icone11&lt;/option&gt;<br />&lt;option value='images/avatars/icone12.gif'&gt;icone12&lt;/option&gt;<br />&lt;option value='images/avatars/icone13.gif'&gt;icone13&lt;/option&gt;<br />&lt;/select&gt;<br />&lt;img src='images/clear_avatar.gif' name='avatarpic' align='absmiddle' border=0&gt;</p>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.kidbook.com.tw/asaprogramer/article.asp?id=23" /> 
	  <id>http://blog.kidbook.com.tw/asaprogramer/default.asp?id=23</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[一個 Java 所寫成的日曆]]></title>
	  <author>
		 <name>FindSome</name>
		 <uri>http://blog.kidbook.com.tw/asaprogramer/</uri>
		 <email>Findsome@mail.imagery.com.tw</email>
	  </author>
	  <category term="" scheme="http://blog.kidbook.com.tw/asaprogramer/default.asp?cateID=10" label="Java&amp;Script" /> 
	  <updated>2008-01-31T17:03:15+08:00</updated>
	  <published>2008-01-31T17:03:15+08:00</published>
		  <summary type="html"><![CDATA[<p>&lt;link href=&quot;images/style.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;<br />&lt;body onLoad=&quot;CreateMonthView(gcrq)&quot;&gt;<br />&lt;table width=&quot;102%&quot; border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;1&quot; bgcolor=&quot;#000000&quot;&gt;<br />&nbsp; &lt;tr&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td width=&quot;6%&quot; height=&quot;28&quot; bgcolor=&quot;#DDDDDD&quot;&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;images/calendar.gif&quot; width=&quot;18&quot; height=&quot;18&quot;&gt;&lt;/div&gt;&lt;/td&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td width=&quot;14%&quot; bgcolor=&quot;#&lt;%if action=&quot;&quot; then%&gt;B3D1FF&lt;%else%&gt;DDDDDD&lt;%end if%&gt;&quot; class=&quot;column_title_black&quot;&nbsp; onMouseOver=&quot;this.style.backgroundColor='B3D1FF'&quot; onMouseOut=&quot;this.style.backgroundColor=''&quot;&gt;&lt;div align=&quot;center&quot;&gt;&lt;a href=&quot;?&quot; class=&quot;head_black&quot;&gt;日程安排&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td width=&quot;20%&quot; bgcolor=&quot;#&lt;%if action=&quot;search&quot; then%&gt;B3D1FF&lt;%else%&gt;DDDDDD&lt;%end if%&gt;&quot; class=&quot;column_title_black&quot; onMouseOver=&quot;this.style.backgroundColor='B3D1FF'&quot; onMouseOut=&quot;this.style.backgroundColor=''&quot;&gt;&lt;div align=&quot;center&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;table width=&quot;96%&quot; border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;tr style=&quot;cursor:hand&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td width=&quot;30%&quot;&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;images/infofind_small.gif&quot; width=&quot;27&quot; height=&quot;26&quot;&gt;&lt;/div&gt;&lt;/td&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td width=&quot;70%&quot;&gt;&lt;a href=&quot;?action=search&quot; target=&quot;mainFrame&quot; class=&quot;head_black&quot;&gt;日程安排查询&lt;/a&gt; &lt;/td&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/tr&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/table&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/div&gt;&lt;/td&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td width=&quot;60%&quot; bgcolor=&quot;#DDDDDD&quot; class=&quot;column_title_black&quot;&gt;&amp;nbsp;&lt;/td&gt;<br />&nbsp; &lt;/tr&gt;<br />&lt;/table&gt;<br />&lt;table width=&quot;98%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;<br />&nbsp; &lt;tr&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td&gt;&amp;nbsp;&lt;/td&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td class=&quot;column_title_while&quot;&gt;&amp;nbsp;&lt;/td&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td&gt;&amp;nbsp;&lt;/td&gt;<br />&nbsp; &lt;/tr&gt;<br />&nbsp; &lt;tr&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td width=&quot;8%&quot;&gt;&lt;div align=&quot;right&quot;&gt;&lt;img src=&quot;images/calendar.gif&quot; width=&quot;18&quot; height=&quot;18&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td width=&quot;81%&quot; class=&quot;column_title_while&quot;&gt;日程安排&lt;/td&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td width=&quot;11%&quot;&gt;&amp;nbsp;&lt;/td&gt;<br />&nbsp; &lt;/tr&gt;<br />&nbsp; &lt;tr&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td&gt;&amp;nbsp;&lt;/td&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td class=&quot;column_title_while&quot;&gt;&amp;nbsp;&lt;/td&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td&gt;&amp;nbsp;&lt;/td&gt;<br />&nbsp; &lt;/tr&gt;<br />&nbsp; &lt;tr&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td colspan=&quot;3&quot; align=&quot;center&quot; valign=&quot;middle&quot;&gt;&lt;input name=&quot;gcrq&quot; type=&quot;hidden&quot; id=&quot;gcrq&quot; value=&quot;&quot;&gt;&lt;/td&gt;<br />&nbsp; &lt;/tr&gt;<br />&nbsp; &lt;tr&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td&gt;&amp;nbsp;&lt;/td&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td&gt;&amp;nbsp;&lt;/td&gt;<br />&nbsp;&nbsp;&nbsp; &lt;td&gt;&amp;nbsp;&lt;/td&gt;<br />&nbsp; &lt;/tr&gt;<br />&lt;/table&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;<br />&lt;Script language=&quot;javascript&quot;&gt; </p>
<p>&lt;!-- </p>
<p>//this is jsMonthView 1.0, author is Chinese DengKang (2002-07-12). </p>
<p>//I allow your do any modify, but i don't bear any liability. </p>
<p>//browser: IE 4 and later </p>
<p>function DefineMonthView(theTextObject){ //the month view construct function <br />&nbsp;this.GetOnlyName = function( ){ //create one and only name on the document <br />&nbsp; var theName = &quot;MV&quot;; //prefix <br />&nbsp; var aryName = new Array(); <br />&nbsp; aryName[0] = &quot;_MonthView&quot;; //the month view main body's name postfix <br />&nbsp; aryName[1] = &quot;_MonthGrid&quot;; //the month view day area's name postfix <br />&nbsp; aryName[2] = &quot;_goPreviousMonth&quot;; //the month view go previous month button's name postfix <br />&nbsp; aryName[3] = &quot;_goNextMonth&quot;; //the month view go next month button's name postfix <br />&nbsp; aryName[4] = &quot;_YearList&quot;; //the month view year list's name postfix <br />&nbsp; aryName[5] = &quot;_MonthList&quot;; //the month view month list's name postfix <br />&nbsp; aryName[6] = &quot;_DayList&quot;; //keep the month view current day's element name postfix <br />&nbsp; aryName[7] = &quot;_goNextYear&quot;; <br />&nbsp; aryName[8] = &quot;_goPreviousYear&quot;; <br />&nbsp; var i = -1, j = 0, maxi = 2000; <br />&nbsp; var exTag = true; <br />&nbsp; while ((exTag == true) &amp;&amp; (i &lt; maxi)){ <br />&nbsp;&nbsp; i++; <br />&nbsp;&nbsp; exTag = false; <br />&nbsp;&nbsp; for (j=0;j&lt;aryName.length;j++){ <br />//&nbsp;&nbsp;&nbsp; if ((j!=2)||(j!=3)){//不显示上月和下月<br />&nbsp;&nbsp;&nbsp;&nbsp; if (document.all.item(theName + i.toString() + aryName[j]) != null){ <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exTag = true; <br />&nbsp;&nbsp;&nbsp;&nbsp; } <br />//&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp; } <br />&nbsp; } <br />&nbsp; if (exTag == false){ <br />&nbsp;&nbsp; return(theName + i.toString()); <br />&nbsp; }<br />&nbsp; else{ <br />&nbsp;&nbsp; return(&quot;_&quot; + theName); <br />&nbsp; } <br />&nbsp;} <br />&nbsp;var theName = this.GetOnlyName(); <br />&nbsp;this.Name = theName; //the month view name <br />&nbsp;this.Source = theTextObject; //the month view act on theTextObject <br />&nbsp;this.MinYear = 1970; //year list min value <br />&nbsp;//return between 1000 and 9999 and &lt;= this.MaxYear <br />&nbsp;this.MaxYear = 2030; //year list max value <br />&nbsp;//return between 1000 and 9999 and &gt;= this.MinYear <br />&nbsp;this.Width = 200; //the month view main body's width <br />&nbsp;this.Height = 120; //the month view main body's height <br />&nbsp;this.DateFormat = &quot;&lt;yyyy&gt;-&lt;mm&gt;-&lt;dd&gt;&quot;; //the date format <br />&nbsp;//&lt;yy&gt; or &lt;yyyy&gt; is year, &lt;m&gt; or &lt;mm&gt; is digital format month, &lt;MMM&gt; or &lt;MMMMMM&gt; is character format month, &lt;d&gt; or &lt;dd&gt; is day, other char unchanged <br />&nbsp;//this function setting year, month and day sequence <br />&nbsp;//example: <br />&nbsp;// &lt;yyyy&gt;-&lt;mm&gt;-&lt;dd&gt; : 2002-04-01 <br />&nbsp;// &lt;yy&gt;.&lt;m&gt;.&lt;d&gt; : 02.4.1 <br />&nbsp;// &lt;yyyy&gt; Year &lt;MMMMMM&gt; Month &lt;d&gt; Day : 2002 Year April Month 1 Day <br />&nbsp;// &lt;m&gt;/&lt;d&gt;/&lt;yy&gt; : 4/1/02 <br />&nbsp;// &lt;MMM&gt; &lt;dd&gt;, &lt;yyyy&gt; : Apr 01, 2002 <br />&nbsp;// &lt;MMMMMM&gt; &lt;d&gt;, &lt;yyyy&gt; : April 1, 2002 <br />&nbsp;// &lt;dd&gt; &lt;MMM&gt; &lt;yyyy&gt; : 01 Apr 2002 <br />&nbsp;// &lt;dd&gt;/&lt;mm&gt;/&lt;yyyy&gt; : 01/04/2002 <br />&nbsp;this.UnselectBgColor = &quot;#FFFFFF&quot;; //the month view default background color <br />&nbsp;this.SelectedBgColor = &quot;#808080&quot;; //the selected date background color <br />&nbsp;this.SelectedColor = &quot;#FFFFFF&quot;; //the selected date front color <br />&nbsp;this.DayBdWidth = &quot;1&quot;; //the day unit border width, unit is px <br />&nbsp;this.DayBdColor = this.UnselectBgColor; //the day unit border color,default is this.UnselectBgColor <br />&nbsp;this.TodayBdColor = &quot;#&quot;; //denote today's date border color <br />&nbsp;this.InvalidColor = &quot;#808080&quot;; //it is not current month day front color <br />&nbsp;this.ValidColor = &quot;#0000FF&quot;; //it is current month day front color <br />&nbsp;this.WeekendBgColor = this.UnselectBgColor; //the weekend background color, default is this.UnselectBgColor <br />&nbsp;this.WeekendColor = this.ValidColor; //the weekend front color, default is this.ValidColor <br />&nbsp;this.YearListStyle = &quot;font-size:12px; font-family:宋体;&quot;; //the year list's style <br />&nbsp;this.MonthListStyle = &quot;font-size:12px; font-family:宋体;&quot;; //the month list's style <br />&nbsp;this.MonthName = new Array(); //month name list, font is include this.MonthListStyle <br />&nbsp;this.MonthName[0] = &quot;1月&quot;; <br />&nbsp;this.MonthName[1] = &quot;2月&quot;; <br />&nbsp;this.MonthName[2] = &quot;3月&quot;; <br />&nbsp;this.MonthName[3] = &quot;4月&quot;; <br />&nbsp;this.MonthName[4] = &quot;5月&quot;; <br />&nbsp;this.MonthName[5] = &quot;6月&quot;; <br />&nbsp;this.MonthName[6] = &quot;7月&quot;; <br />&nbsp;this.MonthName[7] = &quot;8月&quot;; <br />&nbsp;this.MonthName[8] = &quot;9月&quot;; <br />&nbsp;this.MonthName[9] = &quot;10月&quot;; <br />&nbsp;this.MonthName[10] = &quot;11月&quot;; <br />&nbsp;this.MonthName[11] = &quot;12月&quot;; <br />&nbsp;this.TitleStyle = &quot;cursor:default; color:#000000; background-color:&quot; + this.UnselectBgColor + &quot;; font-size:16px; font-weight:bolder; font-family:Times new roman; text-align:center; vertical-align:bottom;&quot;; //the month view title area's style <br />&nbsp;this.WeekName = new Array(); //week name list, font is include this.TitleStyle <br />&nbsp;this.WeekName[0] = &quot;日&quot;; <br />&nbsp;this.WeekName[1] = &quot;一&quot;; <br />&nbsp;this.WeekName[2] = &quot;二&quot;; <br />&nbsp;this.WeekName[3] = &quot;三&quot;; <br />&nbsp;this.WeekName[4] = &quot;四&quot;; <br />&nbsp;this.WeekName[5] = &quot;五&quot;; <br />&nbsp;this.WeekName[6] = &quot;六&quot;; <br />&nbsp;this.FooterStyle = &quot;cursor:hand; color:#FF0000; background-color:&quot; + this.UnselectBgColor + &quot;; font-size:18px; font-family:Verdana; text-align:left; vertical-align:middle;&quot;; //the month footer area's style <br />&nbsp;this.TodayTitle = &quot;今天:&quot;; //today tip string, font is include this.FooterStyle <br />&nbsp;this.MonthBtStyle = &quot;font-family:Marlett; font-size:12px;&quot;; //the change month button style <br />&nbsp;this.PreviousMonthText = &quot;3&quot;; //the go previous month button text <br />&nbsp;//font is include this.MonthBtStyle <br />&nbsp;this.NextMonthText = &quot;4&quot;; //the go next month button text <br />&nbsp;//font is include this.MonthBtStyle <br />&nbsp;this.MonthGridStyle = &quot;border-width:1px; border-style:solid; border-color:#000000;&quot;; //the month view main body's default style <br />&nbsp;this.HeaderStyle = &quot;height:32px; background-color:menu;&quot;; //the month view header area's style <br />&nbsp;this.LineBgStyle = &quot;height:10px; background-color:&quot; + this.UnselectBgColor + &quot;; text-align:center; vertical-align:middle;&quot;; //the month view title area and day area compart area background style <br />&nbsp;this.LineStyle = &quot;width:90%; height:1px; background-color:#000000;&quot;; //the month view title area and day area compart area front style <br />&nbsp;this.DayStyle = &quot;cursor:hand; font-size:12px; font-family:Verdana; text-align:center; vertical-align:middle;&quot;; //the month view day area's style <br />&nbsp;this.OverDayStyle = &quot;this.style.textDecoration='underline';&quot;; //the mouse over a day style <br />&nbsp;this.OutDayStyle = &quot;this.style.textDecoration='none';&quot;; //the mouse out a day style <br />&nbsp;this.GetoffsetLeft = function(theObject){ //return theObject's absolute offsetLeft <br />&nbsp; var absLeft = 0; <br />&nbsp; var thePosition=&quot;&quot;; <br />&nbsp; var tmpObject = theObject; <br />&nbsp; while (tmpObject != null){ <br />&nbsp;&nbsp; thePosition = tmpObject.position; <br />&nbsp;&nbsp; tmpObject.position = &quot;static&quot;; <br />&nbsp;&nbsp; absLeft += tmpObject.offsetLeft; <br />&nbsp;&nbsp; tmpObject.position = thePosition; <br />&nbsp;&nbsp; tmpObject = tmpObject.offsetParent; <br />&nbsp; } <br />&nbsp; return absLeft; <br />&nbsp;} <br />&nbsp;this.GetoffsetTop = function(theObject){ //return theObj's absolute offsetTop <br />&nbsp; var absTop = 0; <br />&nbsp; var thePosition = &quot;&quot;; <br />&nbsp; var tmpObject = theObject; <br />&nbsp; while (tmpObject != null){ <br />&nbsp;&nbsp; thePosition = tmpObject.position; <br />&nbsp;&nbsp; tmpObject.position = &quot;static&quot;; <br />&nbsp;&nbsp; absTop += tmpObject.offsetTop; <br />&nbsp;&nbsp; tmpObject.position = thePosition; <br />&nbsp;&nbsp; tmpObject = tmpObject.offsetParent; <br />&nbsp; } <br />&nbsp; return absTop; <br />&nbsp;} <br />&nbsp;this.GetFormatYear = function(theYear){//format theYear to 4 digit <br />&nbsp; var tmpYear = theYear; <br />&nbsp; if (tmpYear &lt; 100){ <br />&nbsp;&nbsp; tmpYear += 1900; <br />&nbsp;&nbsp; if (tmpYear &lt; 1970){ <br />&nbsp;&nbsp;&nbsp; tmpYear += 100; <br />&nbsp;&nbsp; } <br />&nbsp; } <br />&nbsp; if (tmpYear &lt; this.MinYear){ <br />&nbsp;&nbsp; tmpYear = this.MinYear; <br />&nbsp; } <br />&nbsp; if (tmpYear &gt; this.MaxYear){ <br />&nbsp;&nbsp; tmpYear = this.MaxYear; <br />&nbsp; } <br />&nbsp; return(tmpYear); <br />&nbsp;} <br />&nbsp;this.GetMonthDays = function(theYear, theMonth){ //get theYear and theMonth days number <br />&nbsp; var theDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); <br />&nbsp; var theMonthDay = 0, tmpYear = this.GetFormatYear(theYear); <br />&nbsp; theMonthDay = theDays[theMonth]; <br />&nbsp; if (theMonth == 1){ //theMonth is February <br />&nbsp;&nbsp; if(((tmpYear % 4 == 0) &amp;&amp; (tmpYear % 100 != 0)) || (tmpYear % 400 == 0)){ <br />&nbsp;&nbsp;&nbsp; theMonthDay++; <br />&nbsp;&nbsp; } <br />&nbsp; } <br />&nbsp; return(theMonthDay); <br />&nbsp;} <br />&nbsp;this.SetDateFormat = function(theYear, theMonth, theDay){//format a date to this.DateFormat <br />&nbsp; var theDate = this.DateFormat; <br />&nbsp; var tmpYear = this.GetFormatYear(theYear); <br />&nbsp;&nbsp; <br />&nbsp; var tmpMonth = theMonth; <br />&nbsp; if (tmpMonth &lt; 0){ <br />&nbsp;&nbsp; tmpMonth = 0; <br />&nbsp; } <br />&nbsp; if (tmpMonth &gt; 11){ <br />&nbsp;&nbsp; tmpMonth = 11; <br />&nbsp; } <br />&nbsp; var tmpDay = theDay; <br />&nbsp; if (tmpDay &lt; 1){ <br />&nbsp;&nbsp; tmpDay = 1; <br />&nbsp; }<br />&nbsp; else{ <br />&nbsp;&nbsp; tmpDay = this.GetMonthDays(tmpYear, tmpMonth); <br />&nbsp;&nbsp; if (theDay &lt; tmpDay){ <br />&nbsp;&nbsp;&nbsp; tmpDay = theDay; <br />&nbsp;&nbsp; } <br />&nbsp; } <br />&nbsp; theDate = theDate.replace(/&lt;yyyy&gt;/g, tmpYear.toString()); <br />&nbsp; theDate = theDate.replace(/&lt;yy&gt;/g, tmpYear.toString().substr(2,2)); <br />&nbsp; theDate = theDate.replace(/&lt;MMMMMM&gt;/g, this.MonthName[tmpMonth]); <br />&nbsp; theDate = theDate.replace(/&lt;MMM&gt;/g, this.MonthName[tmpMonth].substr(0,3)); <br />&nbsp; if (theMonth &lt; 9){ <br />&nbsp;&nbsp; theDate = theDate.replace(/&lt;mm&gt;/g, &quot;0&quot; + (tmpMonth + 1).toString()); <br />&nbsp; }else{ <br />&nbsp;&nbsp; theDate = theDate.replace(/&lt;mm&gt;/g, (tmpMonth + 1).toString()); <br />&nbsp; } <br />&nbsp; theDate = theDate.replace(/&lt;m&gt;/g, (tmpMonth + 1).toString()); <br />&nbsp; if (theDay &lt; 10){ <br />&nbsp;&nbsp; theDate = theDate.replace(/&lt;dd&gt;/g, &quot;0&quot; + tmpDay.toString()); <br />&nbsp; }else{ <br />&nbsp;&nbsp; theDate = theDate.replace(/&lt;dd&gt;/g, tmpDay.toString()); <br />&nbsp; } <br />&nbsp; theDate = theDate.replace(/&lt;d&gt;/g, tmpDay.toString()); <br />&nbsp; return(theDate); <br />&nbsp;} <br />&nbsp;this.GetTextDate = function(theString){ //convert a string to a date, if the string is not a date, return a empty string <br />&nbsp; var i = 0, tmpChar = &quot;&quot;, find_tag = &quot;&quot;; <br />&nbsp; var start_at = 0, end_at = 0, year_at = 0, month_at = 0, day_at = 0; <br />&nbsp; var tmp_at = 0, one_at = 0, two_at = 0, one_days = 0, two_days = 0; <br />&nbsp; var aryDate = new Array(); <br />&nbsp; var tmpYear = -1, tmpMonth = -1, tmpDay = -1; <br />&nbsp; var tmpDate = theString.toLowerCase(); <br />&nbsp; var defDate = &quot;&quot;; <br />&nbsp; end_at = tmpDate.length; <br />&nbsp; for (i=1;i&lt;end_at;i++){ <br />&nbsp;&nbsp; if (tmpDate.charAt(i)==&quot;0&quot;){ <br />&nbsp;&nbsp;&nbsp; tmpChar = tmpDate.charAt(i-1); <br />&nbsp;&nbsp;&nbsp; if (tmpChar&lt;&quot;0&quot; || tmpChar&gt;&quot;9&quot;){ <br />&nbsp;&nbsp;&nbsp;&nbsp; tmpDate = tmpDate.substr(0,i-1) + &quot;-&quot; + tmpDate.substr(i+1); <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp; } <br />&nbsp; } <br />&nbsp; for (i=0;i&lt;9;i++){ <br />&nbsp;&nbsp; tmpDate = tmpDate.replace(this.MonthName[i].toLowerCase().substr(0,3), &quot;-00&quot; + (i+1).toString() + &quot;-&quot;); <br />&nbsp; } <br />&nbsp; for (i=9;i&lt;12;i++){ <br />&nbsp;&nbsp; tmpDate = tmpDate.replace(this.MonthName[i].toLowerCase().substr(0,3), &quot;-0&quot; + (i+1).toString() + &quot;-&quot;); <br />&nbsp; } <br />&nbsp; tmpDate = tmpDate.replace(/jan/g, &quot;-001-&quot;); <br />&nbsp; tmpDate = tmpDate.replace(/feb/g, &quot;-002-&quot;); <br />&nbsp; tmpDate = tmpDate.replace(/mar/g, &quot;-003-&quot;); <br />&nbsp; tmpDate = tmpDate.replace(/apr/g, &quot;-004-&quot;); <br />&nbsp; tmpDate = tmpDate.replace(/may/g, &quot;-005-&quot;); <br />&nbsp; tmpDate = tmpDate.replace(/jun/g, &quot;-006-&quot;); <br />&nbsp; tmpDate = tmpDate.replace(/jul/g, &quot;-007-&quot;); <br />&nbsp; tmpDate = tmpDate.replace(/aug/g, &quot;-008-&quot;); <br />&nbsp; tmpDate = tmpDate.replace(/sep/g, &quot;-009-&quot;); <br />&nbsp; tmpDate = tmpDate.replace(/oct/g, &quot;-010-&quot;); <br />&nbsp; tmpDate = tmpDate.replace(/nov/g, &quot;-011-&quot;); <br />&nbsp; tmpDate = tmpDate.replace(/dec/g, &quot;-012-&quot;); <br />&nbsp; for (i=0;i&lt;tmpDate.length;i++){ <br />&nbsp;&nbsp; tmpChar = tmpDate.charAt(i); <br />&nbsp;&nbsp; if ((tmpChar&lt;&quot;0&quot; || tmpChar&gt;&quot;9&quot;) &amp;&amp; (tmpChar != &quot;-&quot;)){ <br />&nbsp;&nbsp;&nbsp; tmpDate = tmpDate.replace(tmpChar,&quot;-&quot;) <br />&nbsp;&nbsp; } <br />&nbsp; } <br />&nbsp; while(tmpDate.indexOf(&quot;--&quot;) != -1){ <br />&nbsp;&nbsp; tmpDate = tmpDate.replace(/--/g,&quot;-&quot;); <br />&nbsp; } <br />&nbsp; start_at = 0; <br />&nbsp; end_at = tmpDate.length-1; <br />&nbsp; while (tmpDate.charAt(start_at)==&quot;-&quot;){ <br />&nbsp;&nbsp; start_at++; <br />&nbsp; } <br />&nbsp; while (tmpDate.charAt(end_at)==&quot;-&quot;){ <br />&nbsp;&nbsp; end_at--; <br />&nbsp; } <br />&nbsp; if (start_at &lt; end_at+1){ <br />&nbsp;&nbsp; tmpDate = tmpDate.substring(start_at,end_at+1); <br />&nbsp; }<br />&nbsp; else{ <br />&nbsp;&nbsp; tmpDate = &quot;&quot;; <br />&nbsp; } <br />&nbsp; aryDate = tmpDate.split(&quot;-&quot;); <br />&nbsp; if (aryDate.length != 3){ <br />&nbsp;&nbsp; return(defDate); <br />&nbsp; } <br />&nbsp; for (i=0;i&lt;3;i++){ <br />&nbsp;&nbsp; if (parseInt(aryDate[i],10)&lt;1){ <br />&nbsp;&nbsp;&nbsp; aryDate[i] = &quot;1&quot;; <br />&nbsp;&nbsp; } <br />&nbsp; } <br />&nbsp; find_tag=&quot;000&quot;; <br />&nbsp; for (i=2;i&gt;=0;i--){ <br />&nbsp;&nbsp; if (aryDate[i].length==3){ <br />&nbsp;&nbsp;&nbsp; if (aryDate[i]&gt;=&quot;001&quot; &amp;&amp; aryDate[i]&lt;=&quot;012&quot;){ <br />&nbsp;&nbsp;&nbsp;&nbsp; tmpMonth = parseInt(aryDate[i],10)-1; <br />&nbsp;&nbsp;&nbsp;&nbsp; switch (i){ <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 0: <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; find_tag = &quot;100&quot;; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; one_at = parseInt(aryDate[1],10); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; two_at = parseInt(aryDate[2],10); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 1: <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; find_tag = &quot;010&quot;; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; one_at = parseInt(aryDate[0],10); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; two_at = parseInt(aryDate[2],10); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 2: <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; find_tag = &quot;001&quot;; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; one_at = parseInt(aryDate[0],10); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; two_at = parseInt(aryDate[1],10); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp; } <br />&nbsp; } <br />&nbsp; if (find_tag!=&quot;000&quot;){ <br />&nbsp;&nbsp; one_days = this.GetMonthDays(two_at,tmpMonth); <br />&nbsp;&nbsp; two_days = this.GetMonthDays(one_at,tmpMonth); <br />&nbsp;&nbsp; if ((one_at&gt;one_days)&amp;&amp;(two_at&gt;two_days)){ <br />&nbsp;&nbsp;&nbsp; return(defDate); <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; if ((one_at&lt;=one_days)&amp;&amp;(two_at&gt;two_days)){ <br />&nbsp;&nbsp;&nbsp; tmpYear = this.GetFormatYear(two_at); <br />&nbsp;&nbsp;&nbsp; tmpDay = one_at; <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; if ((one_at&gt;one_days)&amp;&amp;(two_at&lt;=two_days)){ <br />&nbsp;&nbsp;&nbsp; tmpYear = this.GetFormatYear(one_at); <br />&nbsp;&nbsp;&nbsp; tmpDay = two_at; <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; if ((one_at&lt;=one_days)&amp;&amp;(two_at&lt;=two_days)){ <br />&nbsp;&nbsp;&nbsp; tmpYear = this.GetFormatYear(one_at); <br />&nbsp;&nbsp;&nbsp; tmpDay = two_at; <br />&nbsp;&nbsp;&nbsp; tmpDate = this.DateFormat; <br />&nbsp;&nbsp;&nbsp; year_at = tmpDate.indexOf(&quot;&lt;yyyy&gt;&quot;); <br />&nbsp;&nbsp;&nbsp; if (year_at == -1){ <br />&nbsp;&nbsp;&nbsp;&nbsp; year_at = tmpDate.indexOf(&quot;&lt;yy&gt;&quot;); <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; day_at = tmpDate.indexOf(&quot;&lt;dd&gt;&quot;); <br />&nbsp;&nbsp;&nbsp; if (day_at == -1){ <br />&nbsp;&nbsp;&nbsp;&nbsp; day_at = tmpDate.indexOf(&quot;&lt;d&gt;&quot;); <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; if (year_at &gt;= day_at){ <br />&nbsp;&nbsp;&nbsp;&nbsp; tmpYear = this.GetFormatYear(two_at); <br />&nbsp;&nbsp;&nbsp;&nbsp; tmpDay = one_at; <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; return(new Date(tmpYear, tmpMonth, tmpDay)); <br />&nbsp; } <br />&nbsp; find_tag = &quot;000&quot;; <br />&nbsp; for (i=2;i&gt;=0;i--){ <br />&nbsp;&nbsp; if (parseInt(aryDate[i],10)&gt;31){ <br />&nbsp;&nbsp;&nbsp; tmpYear = this.GetFormatYear(parseInt(aryDate[i],10)); <br />&nbsp;&nbsp;&nbsp; switch (i){ <br />&nbsp;&nbsp;&nbsp;&nbsp; case 0: <br />&nbsp;&nbsp;&nbsp;&nbsp; find_tag = &quot;100&quot;; <br />&nbsp;&nbsp;&nbsp;&nbsp; one_at = parseInt(aryDate[1],10); <br />&nbsp;&nbsp;&nbsp;&nbsp; two_at = parseInt(aryDate[2],10); <br />&nbsp;&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp;&nbsp;&nbsp; case 1: <br />&nbsp;&nbsp;&nbsp;&nbsp; find_tag = &quot;010&quot;; <br />&nbsp;&nbsp;&nbsp;&nbsp; one_at = parseInt(aryDate[0],10); <br />&nbsp;&nbsp;&nbsp;&nbsp; two_at = parseInt(aryDate[2],10); <br />&nbsp;&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp;&nbsp;&nbsp; case 2: <br />&nbsp;&nbsp;&nbsp;&nbsp; find_tag = &quot;001&quot;; <br />&nbsp;&nbsp;&nbsp;&nbsp; one_at = parseInt(aryDate[0],10); <br />&nbsp;&nbsp;&nbsp;&nbsp; two_at = parseInt(aryDate[1],10); <br />&nbsp;&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp; } <br />&nbsp; } <br />&nbsp; if (find_tag==&quot;000&quot;){ <br />&nbsp;&nbsp; tmpDate = this.DateFormat; <br />&nbsp;&nbsp; year_at = tmpDate.indexOf(&quot;&lt;yyyy&gt;&quot;); <br />&nbsp;&nbsp; if (year_at == -1){year_at = tmpDate.indexOf(&quot;&lt;yy&gt;&quot;);} <br />&nbsp;&nbsp; month_at = tmpDate.indexOf(&quot;&lt;MMMMMM&gt;&quot;); <br />&nbsp;&nbsp; if (month_at == -1){month_at = tmpDate.indexOf(&quot;&lt;MMM&gt;&quot;);} <br />&nbsp;&nbsp; if (month_at == -1){month_at = tmpDate.indexOf(&quot;&lt;mm&gt;&quot;);} <br />&nbsp;&nbsp; if (month_at == -1){month_at = tmpDate.indexOf(&quot;&lt;m&gt;&quot;);} <br />&nbsp;&nbsp; day_at = tmpDate.indexOf(&quot;&lt;dd&gt;&quot;); <br />&nbsp;&nbsp; if (day_at == -1){day_at = tmpDate.indexOf(&quot;&lt;d&gt;&quot;);} <br />&nbsp;&nbsp; if ((year_at&gt;month_at)&amp;&amp;(year_at&gt;day_at)){find_tag=&quot;001&quot;} <br />&nbsp;&nbsp; if ((year_at&gt;month_at)&amp;&amp;(year_at&lt;=day_at)){find_tag=&quot;010&quot;;} <br />&nbsp;&nbsp; if ((year_at&lt;=month_at)&amp;&amp;(year_at&gt;day_at)){find_tag=&quot;010&quot;;} <br />&nbsp;&nbsp; if ((year_at&lt;=month_at)&amp;&amp;(year_at&lt;=day_at)){find_tag=&quot;100&quot;;} <br />&nbsp;&nbsp; switch (find_tag){ <br />&nbsp;&nbsp;&nbsp; case &quot;100&quot;: <br />&nbsp;&nbsp;&nbsp; tmpYear = parseInt(aryDate[0],10); <br />&nbsp;&nbsp;&nbsp; one_at = parseInt(aryDate[1],10); <br />&nbsp;&nbsp;&nbsp; two_at = parseInt(aryDate[2],10); <br />&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp;&nbsp; case &quot;010&quot;: <br />&nbsp;&nbsp;&nbsp; one_at = parseInt(aryDate[0],10); <br />&nbsp;&nbsp;&nbsp; tmpYear = parseInt(aryDate[1],10); <br />&nbsp;&nbsp;&nbsp; two_at = parseInt(aryDate[2],10); <br />&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp;&nbsp; case &quot;001&quot;: <br />&nbsp;&nbsp;&nbsp; one_at = parseInt(aryDate[0],10); <br />&nbsp;&nbsp;&nbsp; two_at = parseInt(aryDate[1],10); <br />&nbsp;&nbsp;&nbsp; tmpYear = parseInt(aryDate[2],10); <br />&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; tmpYear = this.GetFormatYear(tmpYear); <br />&nbsp; } <br />&nbsp; if (find_tag!=&quot;000&quot;){ <br />&nbsp;&nbsp; if ((one_at&gt;12)&amp;&amp;(two_at&gt;12)){ <br />&nbsp;&nbsp;&nbsp; return(defDate); <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; if (one_at&lt;=12){ <br />&nbsp;&nbsp;&nbsp; if (two_at &gt; this.GetMonthDays(tmpYear,one_at-1)){ return(new Date(tmpYear, one_at-1, this.GetMonthDays(tmpYear,one_at-1))); <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; if (two_at&gt;12){ <br />&nbsp;&nbsp;&nbsp; return(new Date(tmpYear, one_at-1, two_at)); <br />&nbsp;&nbsp; } <br />&nbsp; } <br />&nbsp; if (two_at&lt;=12){ <br />&nbsp;&nbsp; if (one_at &gt; this.GetMonthDays(tmpYear,two_at-1)){ <br />&nbsp;&nbsp;&nbsp; return(new Date(tmpYear, two_at-1, this.GetMonthDays(tmpYear,two_at-1))); <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; if (one_at&gt;12){ <br />&nbsp;&nbsp;&nbsp; return(new Date(tmpYear, two_at-1, one_at)); <br />&nbsp;&nbsp; } <br />&nbsp; } <br />&nbsp; if ((one_at&lt;=12)&amp;&amp;(two_at&lt;=12)){ <br />&nbsp;&nbsp; tmpMonth = one_at-1; <br />&nbsp;&nbsp; tmpDay = two_at; <br />&nbsp;&nbsp; tmpDate = this.DateFormat; <br />&nbsp;&nbsp; month_at = tmpDate.indexOf(&quot;&lt;MMMMMM&gt;&quot;); <br />&nbsp;&nbsp; if (month_at == -1){month_at = tmpDate.indexOf(&quot;&lt;MMM&gt;&quot;);} <br />&nbsp;&nbsp; if (month_at == -1){month_at = tmpDate.indexOf(&quot;&lt;mm&gt;&quot;);} <br />&nbsp;&nbsp; if (month_at == -1){month_at = tmpDate.indexOf(&quot;&lt;m&gt;&quot;);} <br />&nbsp;&nbsp; day_at = tmpDate.indexOf(&quot;&lt;dd&gt;&quot;); <br />&nbsp;&nbsp; if (day_at == -1){day_at = tmpDate.indexOf(&quot;&lt;d&gt;&quot;);} <br />&nbsp;&nbsp; if (month_at &gt;= day_at){ <br />&nbsp;&nbsp;&nbsp; tmpMonth = two_at-1; <br />&nbsp;&nbsp;&nbsp; tmpDay = one_at; <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; return(new Date(tmpYear, tmpMonth, tmpDay)); <br />&nbsp; } <br />&nbsp;} <br />} <br />&nbsp;this.CreateYearList = function(MinYear, MaxYear){ //create year list <br />&nbsp; var theName = this.Name; <br />&nbsp; var theYearObject = document.all.item(theName + &quot;_YearList&quot;); <br />&nbsp; if (theYearObject == null){ <br />&nbsp;&nbsp; return; <br />&nbsp; } <br />&nbsp; var theYear = 0; <br />&nbsp; var theYearHTML = &quot;&lt;select id=\&quot;&quot; + theName + &quot;_YearList\&quot; tabIndex=\&quot;-1\&quot; onChange=\&quot;document.jsMonthView.UpdateMonthGrid(this)\&quot; style=\&quot;font-size: 12pt; border: 1px #666666 outset;COLOR: #000066; font-weight: bold;background-color: #F4F8FB\&quot;&gt;&quot;; <br />&nbsp; for (theYear = MinYear; theYear &lt;= MaxYear; theYear++){ <br />&nbsp;&nbsp; theYearHTML += &quot;&lt;option value=\&quot;&quot; + theYear.toString() + &quot;\&quot;&gt;&quot; + theYear.toString() + &quot;&lt;/option&gt;&quot;; <br />&nbsp; } <br />&nbsp; theYearHTML += &quot;&lt;/select&gt;&quot;; <br />&nbsp; theYearObject.outerHTML = theYearHTML; <br />&nbsp;} <br />&nbsp;this.CreateMonthList = function( ){ //create month list <br />&nbsp; var theName = this.Name; var theMonthObject = document.all.item(theName + &quot;_MonthList&quot;); <br />&nbsp; if (theMonthObject == null){ <br />&nbsp;&nbsp; return; <br />&nbsp; } <br />&nbsp; var theMonth = 0; <br />&nbsp; var theMonthHTML = &quot;&lt;select id=\&quot;&quot; + theName + &quot;_MonthList\&quot; style=\&quot;font-size: 12pt; border: 1px #666666 outset;COLOR: #000066; font-weight: bold;background-color: #F4F8FB\&quot; tabIndex=\&quot;-1\&quot; onChange=\&quot;document.jsMonthView.UpdateMonthGrid(this)\&quot;&gt;&quot;; <br />&nbsp; for (theMonth = 0; theMonth &lt; 12; theMonth++){ <br />&nbsp;&nbsp; theMonthHTML += &quot;&lt;option value=\&quot;&quot; + theMonth.toString() + &quot;\&quot;&gt;&quot; + this.MonthName[theMonth] + &quot;&lt;/option&gt;&quot;; <br />&nbsp; } <br />&nbsp; theMonthHTML +=&quot;&lt;/select&gt;&quot;; <br />&nbsp; theMonthObject.outerHTML = theMonthHTML; <br />&nbsp;} <br />&nbsp;this.setDayList = function(theYear, theMonth, theDay){ //set the month view show a date <br />&nbsp; var theName = this.Name; <br />&nbsp; var theDayObject = document.all.item(theName + &quot;_DayList&quot;); <br />&nbsp; if (theDayObject == null){ <br />&nbsp;&nbsp; return; <br />&nbsp; } <br />&nbsp; theDayObject.value = theDay.toString(); <br />&nbsp; var theFirstDay = new Date(theYear, theMonth, 1); <br />&nbsp; var theCurrentDate = new Date(); <br />&nbsp; var theWeek = theFirstDay.getDay(); <br />&nbsp; if (theWeek == 0){ <br />&nbsp;&nbsp; theWeek = 7; <br />&nbsp; } <br />&nbsp; var theLeftDay = 0; <br />&nbsp; if (theMonth == 0){ <br />&nbsp;&nbsp; theLeftDay = 31; <br />&nbsp; }else{ <br />&nbsp;&nbsp; theLeftDay = this.GetMonthDays(theYear, theMonth - 1); <br />&nbsp; } <br />&nbsp; var theRightDay = this.GetMonthDays(theYear, theMonth); <br />&nbsp; var theCurrentDay = theLeftDay - theWeek + 1; <br />&nbsp; var offsetMonth = -1; //the month is previous month <br />&nbsp; var theColor = this.InvalidColor; <br />&nbsp; var theBgColor = this.UnselectBgColor; <br />&nbsp; var theBdColor = theBgColor; <br />&nbsp; var WeekId = 0 <br />&nbsp; var DayId = 0; <br />&nbsp; var theStyle = &quot;&quot;; <br />&nbsp; var theDayHTML = &quot;&lt;table width=\&quot;100%\&quot; height=\&quot;100%\&quot; border='0' cellpadding='0' cellspacing='1' bgcolor='#000000'&gt;&quot;; <br />&nbsp; theDayHTML += &quot; &lt;tr style=\&quot;&quot; + this.TitleStyle + &quot;\&quot;&gt;&quot;; <br />&nbsp; for (DayId = 0; DayId &lt; 7; DayId++){ <br />&nbsp;&nbsp; theDayHTML += &quot; &lt;td width=\&quot;10%\&quot; height='30' valign='middle' background='images/headerbg.gif' class='column_title_black'&gt;&quot; + this.WeekName[DayId] + &quot;&lt;/td&gt;&quot;; <br />&nbsp; } <br />&nbsp; theDayHTML += &quot; &lt;/tr&gt;&quot;; <br />&nbsp; for (WeekId = 0; WeekId &lt; 6; WeekId++){ <br />&nbsp;&nbsp; theDayHTML += &quot; &lt;tr style=\&quot;&quot; + this.DayStyle + &quot;\&quot;&gt;&quot;; <br />&nbsp;&nbsp; for (DayId = 0; DayId &lt; 7; DayId++){ <br />//&nbsp;&nbsp;&nbsp; alert('theCurrentDay:'+theCurrentDay+'&nbsp;&nbsp;&nbsp;&nbsp; theLeftDay:'+theLeftDay+'&nbsp;&nbsp;&nbsp;&nbsp; theRightDay:'+theRightDay+'&nbsp;&nbsp;&nbsp;&nbsp; WeekId:'+WeekId);<br />&nbsp;&nbsp;&nbsp; if ((theCurrentDay &gt; theLeftDay) &amp;&amp; (WeekId &lt; 3)){ <br />&nbsp;&nbsp;&nbsp;&nbsp; offsetMonth++; //the month is current month; <br />&nbsp;&nbsp;&nbsp;&nbsp; theCurrentDay = 1; <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; if ((theCurrentDay &gt; theRightDay) &amp;&amp; (WeekId &gt; 3)){ <br />&nbsp;&nbsp;&nbsp;&nbsp; offsetMonth++; //the month is next month; <br />&nbsp;&nbsp;&nbsp;&nbsp; theCurrentDay = 1; <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; switch (offsetMonth){ <br />&nbsp;&nbsp;&nbsp;&nbsp; case -1: <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; theColor = this.InvalidColor; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp;&nbsp;&nbsp; case 1: <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; theColor = this.InvalidColor; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp;&nbsp;&nbsp; case 0: <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((DayId==0)||(DayId==6)){ <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; theColor = this.WeekendColor; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else{ <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; theColor = this.ValidColor; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; if ((DayId==0)||(DayId==6)){ <br />&nbsp;&nbsp;&nbsp;&nbsp; theBgColor = this.WeekendBgColor; <br />&nbsp;&nbsp;&nbsp; }else{ <br />&nbsp;&nbsp;&nbsp;&nbsp; theBgColor = this.UnselectBgColor; <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; theBdColor = this.DayBdColor; <br />&nbsp;&nbsp;&nbsp; if ((theCurrentDay == theDay) &amp;&amp; (offsetMonth == 0)){ <br />&nbsp;&nbsp;&nbsp;&nbsp; theColor = this.SelectedColor; <br />&nbsp;&nbsp;&nbsp;&nbsp; theBgColor = this.SelectedBgColor; <br />&nbsp;&nbsp;&nbsp;&nbsp; theBdColor = theBgColor; <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; if ((theYear == theCurrentDate.getFullYear()) &amp;&amp; (theMonth == theCurrentDate.getMonth()) &amp;&amp; (theCurrentDay == theCurrentDate.getDate()) &amp;&amp; (offsetMonth == 0)){ <br />&nbsp;&nbsp;&nbsp;&nbsp; theBdColor = this.TodayBdColor; <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; theStyle = &quot;border:&quot; + this.DayBdWidth + &quot;px solid &quot; + theBdColor + &quot;; color:&quot; + theColor + &quot;; background-color:&quot; + theBgColor + &quot;;&quot;; <br />&nbsp;&nbsp;&nbsp; theDayHTML += &quot; &lt;td style=\&quot;&quot; + theStyle + &quot;\&quot; height='40'&gt;&quot;; <br />&nbsp;&nbsp;&nbsp; if ((((this.GetMonthDays(theYear, theMonth)-theCurrentDay)&gt;10) &amp;&amp; (WeekId &lt; 3))||((((this.GetMonthDays(theYear, theMonth)-theCurrentDay)&lt;=17)) &amp;&amp; (WeekId &gt;= 3))){//测试<br />&nbsp;&nbsp;&nbsp;&nbsp; theDayHTML += &quot;&lt;a href='arrange1.asp?year=&quot;+theYear.toString()+&quot;&amp;month=&quot;+this.MonthName[theMonth].replace('月','')+&quot;&amp;day=&quot;+theCurrentDay.toString()+&quot;' title='查看日程安排' class='arrange'&gt;&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp; theDayHTML += theCurrentDay.toString(); <br />&nbsp;&nbsp;&nbsp;&nbsp; theDayHTML += &quot; &lt;/a&gt;&quot;; <br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; theDayHTML += &quot; &lt;/td&gt;&quot;; <br />&nbsp;&nbsp;&nbsp; theCurrentDay++; <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; theDayHTML += &quot; &lt;/tr&gt;&quot;; <br />&nbsp; } <br />&nbsp; theDayHTML += &quot; &lt;tr style=\&quot;&quot; + this.FooterStyle + &quot;\&quot; onMouseDown=\&quot;document.jsMonthView.CreateMonthGrid(&quot; + theCurrentDate.getFullYear().toString() + &quot;, &quot; + theCurrentDate.getMonth().toString() + &quot;, &quot; + theCurrentDate.getDate().toString() + &quot;);\&quot;&gt;&quot;; <br />&nbsp; theStyle = &quot;border:&quot; + this.DayBdWidth + &quot;px solid &quot; + this.TodayBdColor + &quot;;&quot;; <br />&nbsp; theDayHTML += &quot; &lt;td colspan=\&quot;7\&quot; height='50' align='center'&gt;&lt;font size='5'&gt;&quot; + this.TodayTitle + &quot; &quot; + this.SetDateFormat(theCurrentDate.getFullYear(), theCurrentDate.getMonth(), theCurrentDate.getDate()) +&quot; &lt;/font&gt;&lt;/td&gt;&quot;; <br />&nbsp; theDayHTML += &quot; &lt;/tr&gt;&quot;; <br />&nbsp; theDayHTML += &quot; &lt;/table&gt;&quot;; <br />&nbsp; var theMonthGrid = document.all.item(theName + &quot;_MonthGrid&quot;); <br />&nbsp; theMonthGrid.innerHTML = theDayHTML; <br />&nbsp;} <br />&nbsp;this.CreateMonthGrid = function(theYear, theMonth, theDay){ //refresh the month view to the date, main action is run this.setDayList() and set this.Source.value <br />&nbsp; var theTextObject = this.Source; <br />&nbsp; if (theTextObject == null){ <br />&nbsp;&nbsp; return; <br />&nbsp; } <br />&nbsp; var theName = this.Name; <br />&nbsp; var theYearObject = document.all.item(theName + &quot;_YearList&quot;); <br />&nbsp; var theMonthObject = document.all.item(theName + &quot;_MonthList&quot;); <br />&nbsp; var tmpYear = theYear; <br />&nbsp; var tmpMonth = theMonth; <br />&nbsp; var tmpDay = 1; <br />&nbsp; if (tmpMonth &lt; 0){ <br />&nbsp;&nbsp; tmpYear--; <br />&nbsp;&nbsp; tmpMonth = 11; <br />&nbsp; } <br />&nbsp; if (tmpMonth &gt; 11){ <br />&nbsp;&nbsp; tmpYear++; <br />&nbsp;&nbsp; tmpMonth = 0; <br />&nbsp; } <br />&nbsp; if (tmpYear &lt; this.MinYear){ <br />&nbsp;&nbsp; tmpYear = this.MinYear; <br />&nbsp; } <br />&nbsp; if (tmpYear &gt; this.MaxYear){ <br />&nbsp;&nbsp; tmpYear = this.MaxYear; <br />&nbsp; } <br />&nbsp; if (theDay &lt; 1){ <br />&nbsp;&nbsp; tmpDay = 1; <br />&nbsp; }else{ <br />&nbsp;&nbsp; tmpDay = this.GetMonthDays(tmpYear, tmpMonth); <br />&nbsp;&nbsp; if (theDay &lt; tmpDay){ <br />&nbsp;&nbsp;&nbsp; tmpDay = theDay; <br />&nbsp;&nbsp; } <br />&nbsp; } <br />&nbsp; theYearObject.value = tmpYear; <br />&nbsp; theMonthObject.value = tmpMonth; <br />&nbsp; this.setDayList(tmpYear, tmpMonth, tmpDay); <br />&nbsp; theTextObject.value = this.SetDateFormat(tmpYear, tmpMonth, tmpDay); <br />&nbsp; theTextObject.select(); <br />&nbsp;} <br />&nbsp;this.UpdateMonthGrid = function(theObject){ //run this.CreateMonthGrid() by theObject <br />&nbsp; var theTextObject = this.Source; <br />&nbsp; if (theTextObject == null){ <br />&nbsp;&nbsp; return; <br />&nbsp; } <br />&nbsp; var theName = this.Name; <br />&nbsp; var theYearObject = document.all.item(theName + &quot;_YearList&quot;); <br />&nbsp; var theMonthObject = document.all.item(theName + &quot;_MonthList&quot;); <br />&nbsp; var theDayObject = document.all.item(theName + &quot;_DayList&quot;); <br />&nbsp; var tmpName = theObject.id.substr(theObject.id.lastIndexOf(&quot;_&quot;)); <br />&nbsp; switch (tmpName){ <br />&nbsp; case &quot;_goPreviousMonth&quot;: //go previous month button <br />&nbsp;&nbsp; theObject.disabled = true; <br />&nbsp;&nbsp; this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10) - 1, parseInt(theDayObject.value, 10)); <br />&nbsp;&nbsp; theObject.disabled = false; <br />&nbsp;&nbsp; break; <br />&nbsp; case &quot;_goNextMonth&quot;: //go next month button <br />&nbsp;&nbsp; theObject.disabled = true; <br />&nbsp;&nbsp; this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10) + 1, parseInt(theDayObject.value, 10)); <br />&nbsp;&nbsp; theObject.disabled = false; <br />&nbsp;&nbsp; break; <br />&nbsp; case &quot;_goNextYear&quot;: //go next month button <br />&nbsp;&nbsp; theObject.disabled = true; <br />&nbsp;&nbsp; this.CreateMonthGrid(parseInt(theYearObject.value, 10) + 1, parseInt(theMonthObject.value, 10), parseInt(theDayObject.value, 10)); <br />&nbsp;&nbsp; theObject.disabled = false; <br />&nbsp;&nbsp; break; <br />&nbsp; case &quot;_goPreviousYear&quot;: //go next month button <br />&nbsp;&nbsp; theObject.disabled = true; <br />&nbsp;&nbsp; this.CreateMonthGrid(parseInt(theYearObject.value, 10) - 1, parseInt(theMonthObject.value, 10), parseInt(theDayObject.value, 10)); <br />&nbsp;&nbsp; theObject.disabled = false; <br />&nbsp;&nbsp; break; <br />&nbsp; case &quot;_YearList&quot;: //year list <br />&nbsp;&nbsp; this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10), parseInt(theDayObject.value, 10)); <br />&nbsp;&nbsp; break; <br />&nbsp; case &quot;_MonthList&quot;: //month list <br />&nbsp;&nbsp; this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10), parseInt(theDayObject.value, 10)); <br />&nbsp;&nbsp; break; <br />&nbsp; default: <br />&nbsp;&nbsp; return; <br />&nbsp; } <br />&nbsp;} <br />&nbsp;this.DeleteMonthGrid = function( ){ //check document focus, if blur this.Source then delete this <br />&nbsp; var theName = this.Name; <br />&nbsp; var theDivObject = document.all.item(theName + &quot;_MonthView&quot;); <br />&nbsp; if (theDivObject == null){ <br />&nbsp;&nbsp; return; <br />&nbsp; } <br />&nbsp; var tmpObject = document.activeElement; <br />&nbsp; while (tmpObject != null){ <br />&nbsp;&nbsp; if (tmpObject == this.Source){ <br />&nbsp;&nbsp;&nbsp; return; <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; //if (tmpObject.id == theName + &quot;_MonthView&quot;){ <br />&nbsp;&nbsp; // return; <br />&nbsp;&nbsp; //} <br />&nbsp;&nbsp; //if (tmpObject.id == theName + &quot;_MonthGrid&quot;){ <br />&nbsp;&nbsp; // return; <br />&nbsp;&nbsp; //} <br />&nbsp;&nbsp; if (tmpObject.id == theName + &quot;_goPreviousMonth&quot;){ <br />&nbsp;&nbsp; return; <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; if (tmpObject.id == theName + &quot;_goNextMonth&quot;){ <br />&nbsp;&nbsp; return; <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; if (tmpObject.id == theName + &quot;_goNextYear&quot;){ <br />&nbsp;&nbsp; return; <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; if (tmpObject.id == theName + &quot;_goPreviousYear&quot;){ <br />&nbsp;&nbsp; return; <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; if (tmpObject.id == theName + &quot;_YearList&quot;){ <br />&nbsp;&nbsp; return; <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; if (tmpObject.id == theName + &quot;_MonthList&quot;){ <br />&nbsp;&nbsp; return; <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; if (tmpObject.id == theName + &quot;_DayList&quot;){ <br />&nbsp;&nbsp; return; <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; tmpObject = tmpObject.parentElement; <br />&nbsp; } <br />&nbsp; if (tmpObject == null){ //delete the month view <br />&nbsp;&nbsp; theDivObject.outerHTML = &quot;&quot;; <br />&nbsp;&nbsp; var theDate = new Date(this.GetTextDate(this.Source.value)); <br />&nbsp;&nbsp; if (isNaN(theDate)){ <br />&nbsp;&nbsp;&nbsp; this.Source.value = &quot;&quot;; <br />&nbsp;&nbsp; }else{ <br />&nbsp;&nbsp;&nbsp; this.Source.value = this.SetDateFormat(theDate.getFullYear(), theDate.getMonth(), theDate.getDate()); <br />&nbsp;&nbsp; } <br />&nbsp;&nbsp; this.Source = null; <br />&nbsp; } <br />&nbsp;} <br />&nbsp;this.InitialMonthView = function( ){ <br />&nbsp; var theName = this.Name; <br />&nbsp; var theValue = this.Source.value; <br />&nbsp; var theCurrentDate = new Date(this.GetTextDate(theValue)); <br />&nbsp; if (isNaN(theCurrentDate)){ <br />&nbsp;&nbsp; theCurrentDate = new Date(); <br />&nbsp; } <br />&nbsp; var theDivHTML = &quot;&lt;div id=\&quot;&quot; + theName + &quot;_MonthView\&quot; onBlur=\&quot;document.jsMonthView.DeleteMonthGrid();\&quot;&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;table width='600' height='300' style=\&quot;&quot; + this.MonthGridStyle + &quot;\&quot; cellpadding=\&quot;0\&quot; cellspacing=\&quot;0\&quot;&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;tr&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;td align=\&quot;center\&quot; valign=\&quot;top\&quot;&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;table width=\&quot;100%\&quot; height=\&quot;100%\&quot; border=\&quot;0\&quot; cellspacing=\&quot;0\&quot; cellpadding=\&quot;0\&quot;&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;tr align=\&quot;center\&quot; style=\&quot;&quot; + this.HeaderStyle + &quot;\&quot;&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;td colspan='3' width='100%'&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;input type=\&quot;button\&quot; tabIndex=\&quot;-1\&quot; style=\&quot;&quot; + this.MonthBtStyle + &quot;\&quot; id=\&quot;&quot; + theName + &quot;_goPreviousYear\&quot; value=\&quot;&quot; + this.PreviousMonthText + &quot;\&quot; onClick=\&quot;document.jsMonthView.UpdateMonthGrid(this)\&quot; title='上一年' class='button'&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;select id=\&quot;&quot; + theName + &quot;_YearList\&quot;&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;/select&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;input type=\&quot;button\&quot; tabIndex=\&quot;-1\&quot; style=\&quot;&quot; + this.MonthBtStyle + &quot;\&quot; id=\&quot;&quot; + theName + &quot;_goNextYear\&quot; value=\&quot;&quot; + this.NextMonthText + &quot;\&quot; onClick=\&quot;document.jsMonthView.UpdateMonthGrid(this)\&quot;&nbsp; title='下一年' class='button'&gt;&lt;span style='color: #004080;font-weight: bold;font-size: 18px;'&gt;&amp;nbsp;年&lt;/span&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;input type=\&quot;button\&quot; tabIndex=\&quot;-1\&quot; style=\&quot;&quot; + this.MonthBtStyle + &quot;\&quot; id=\&quot;&quot; + theName + &quot;_goPreviousMonth\&quot; value=\&quot;&quot; + this.PreviousMonthText + &quot;\&quot; onClick=\&quot;document.jsMonthView.UpdateMonthGrid(this)\&quot; title='上一月' class='button'&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;select id=\&quot;&quot; + theName + &quot;_MonthList\&quot;&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;/select&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;input type=\&quot;button\&quot; tabIndex=\&quot;-1\&quot; style=\&quot;&quot; + this.MonthBtStyle + &quot;\&quot; id=\&quot;&quot; + theName + &quot;_goNextMonth\&quot; value=\&quot;&quot; + this.NextMonthText + &quot;\&quot; onClick=\&quot;document.jsMonthView.UpdateMonthGrid(this)\&quot;&nbsp; title='下一月' class='button'&gt;&lt;span style='color: #004080;font-weight: bold;font-size: 18px;'&gt;&amp;nbsp;月&lt;/span&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;input type=\&quot;hidden\&quot; id=\&quot;&quot; + theName + &quot;_DayList\&quot; value=\&quot;1\&quot;&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;/td&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;/tr&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;tr&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;td colspan=\&quot;4\&quot; bgcolor=\&quot;&quot; + this.UnselectBgColor + &quot;\&quot;&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;div id=\&quot;&quot; + theName + &quot;_MonthGrid\&quot;&gt;&lt;br&gt;&lt;/div&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;/td&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;/tr&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;/table&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;/td&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;/tr&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;/table&gt;&quot;; <br />&nbsp; theDivHTML += &quot; &lt;/div&gt;&quot;; <br />&nbsp; document.body.insertAdjacentHTML(&quot;beforeEnd&quot;, theDivHTML); <br />&nbsp; theDivObject = document.all.item(theName + &quot;_MonthView&quot;); <br />&nbsp; theDivObject.style.position = &quot;absolute&quot;; <br />&nbsp; theDivObject.style.posLeft = this.GetoffsetLeft(this.Source)+100; <br />&nbsp; theDivObject.style.posTop = this.GetoffsetTop(this.Source) + this.Source.offsetHeight; <br />&nbsp; this.CreateYearList(this.MinYear, this.MaxYear); <br />&nbsp; this.CreateMonthList(); <br />&nbsp; this.CreateMonthGrid(theCurrentDate.getFullYear(), theCurrentDate.getMonth(), theCurrentDate.getDate()); <br />&nbsp;} <br />} <br />function CreateMonthView(theTextObject){ //the month view create interface, fire at element's onFocus event <br />&nbsp;//if (theTextObject.readOnly == true){ <br />&nbsp;//return; <br />&nbsp;//} <br />&nbsp;if (document.jsMonthView != null){ <br />&nbsp; if (document.jsMonthView.Source == theTextObject){ <br />&nbsp;&nbsp; return; <br />&nbsp; }<br />&nbsp; else{ <br />&nbsp;&nbsp; document.jsMonthView.DeleteMonthGrid(); <br />&nbsp; } <br />&nbsp;} <br />&nbsp;document.jsMonthView = new DefineMonthView(theTextObject); <br />&nbsp;//insert your code, change the month view propertiy <br />&nbsp;//example: <br />&nbsp;// document.jsMonthView.DateFormat = &quot;&lt;MMM&gt; &lt;d&gt;,&lt;yyyy&gt;&quot;; <br />&nbsp;document.jsMonthView.InitialMonthView(); <br />&nbsp;theTextObject.select(); <br />} <br />function DeleteMonthView(theTextObject){ //the month view delete interface, fire at element's onBlur event <br />&nbsp;if (document.jsMonthView == null){ <br />&nbsp; return; <br />&nbsp;} <br />&nbsp;document.jsMonthView.DeleteMonthGrid(); <br />&nbsp;if (document.jsMonthView.Source == null){ <br />&nbsp; document.jsMonthView = null; <br />&nbsp;} <br />} <br />//--&gt; <br />&lt;/SCRIPT&gt; </p>
<p><br />该文章转载自网络大本营：<a href="http://www.xrss.cn/Dev/Other/200610105587.Html">http://www.xrss.cn/Dev/Other/200610105587.Html</a></p>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.kidbook.com.tw/asaprogramer/article.asp?id=22" /> 
	  <id>http://blog.kidbook.com.tw/asaprogramer/default.asp?id=22</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[將ASP代碼移植為VB COM組件]]></title>
	  <author>
		 <name>FindSome</name>
		 <uri>http://blog.kidbook.com.tw/asaprogramer/</uri>
		 <email>Findsome@mail.imagery.com.tw</email>
	  </author>
	  <category term="" scheme="http://blog.kidbook.com.tw/asaprogramer/default.asp?cateID=7" label="ASP" /> 
	  <updated>2007-11-12T11:00:01+08:00</updated>
	  <published>2007-11-12T11:00:01+08:00</published>
		  <summary type="html"><![CDATA[<p>本文是編譯稿件，原文出處：http://www.asptoday.com/articles/20000121.htm <br /><br />你剛剛把最新的龐大的ASP應用程序釋放到網上。文件正確地上載到服務器上，與應用程序的鏈接也 <br />工作良好。在慶祝勝利之前，你想在應用程序的性能上運行一些stats 以便發現它到底有多好。結果 <br />卻發現，本來在開發環境下工作得很好的應用程序實際上運行速度很慢。 <br /><br />對於那些使用Microsoft 軟件包時間不長的人，DNA代表分佈式InterNet 結構，是另一種非常熱門的 <br />n層應用程序結構的首字母縮寫形式。Microsoft 致力於在Internet上展開的分佈式應用程序的開發。 <br />基於這種思路，未來將流行小型的、無狀態的、組件化的應用程序就不足為奇了。 <br /><br /><br /><br />上面是ASP用於n層環境的典型圖示。web類（IIS應用程序）不是必需的，因為ASP可以直接與表述層 <br />或商業規則層組件對話。因為大多數應用程序都是用ASP單獨寫成的，所以一個情理中的問題就是： <br /><br />為什麼要將代碼轉入COM組件？ <br /><br />以我之見，ASP只是用於表述層代碼的，所以我選擇將商業規則邏輯或任何形式的數據存取 <br />都裝入COM組件中。一般情況下，我從一開始就將應用程序的代碼分成各個組件，但是通常你並不能選 <br />擇所要處理的結構，所以代碼移植就是個實際問題。在一個n層應用程序中，你必須盡力把非表述代碼 <br />從ASP中盡快移走。 <br /><br />也許目前你並沒有在進行n層編程，那麼移植代碼的適當時機就是運行性能開始削弱時。通常，這是指 <br />你的老闆說「程序今天運行有點慢」到「你被解雇了」之間這段時間。一旦用戶開始抱怨就晚了。 <br /><br />第二個使用移植代碼的方針是當你有足夠的相似代碼（例如所有的數據存取）可以放在一個包含文件 <br />(.inc) 中以保證一個COM組件時。多少個程序就足夠？這個問題提得好！編寫小型的MTS 組件時，我 <br />發現有一個程序就足夠創建一個COM組件了。但是只有一個程序的COM組件是很罕見的，所以對於這個 <br />問題就需要進行判斷。如果你寫的代碼足夠長，就開始進行模式開發了。當你遭遇到ASP的「陰暗面」 <br />之後（aka COM組件）你就會感覺到其力量。 <br /></p>
<p>當你編寫可以節省時間的ASP代碼時，如果要移植代碼的話，有許多事情需要做。跟隨以下步驟，你會 <br />發現移植代碼沒有什麼麻煩的。 <br /><br />聲明變量類型 <br /><br />Visual Basic 和VBScript 的最大缺點是它允許開發人員未經聲明就使用變量。如果你覺得這是個好處， <br />那麼當你要整個晚上來尋找由一個小小的打字錯誤而造成的邏輯錯誤時，就不再這樣想了。如果你使用 <br />了&quot;Option Explicit&quot;（明確選項）而強制明確聲明了的話，IDE 就會對此進行警告。 <br /><br />&lt; %@ Language=VBScript % &gt; <br />&lt; % Option Explicit % &gt; <br /><br />當你使用Option Explicit時，要記住它剛好在@ declarations下面。不注意這一點會導致一個小小的 <br />錯誤信息。 <br /><br />Microsoft VBScript compilation error '800a0400' <br /><br />Expected statement <br /><br />/test.asp, line 4 <br /><br />Option Explicit <br /><br />^ <br /><br />現在挑戰來了。VBScript 允許將變量是任何數據類型，只要它是variant。這就是說你只能把變量 <br />聲明為variants。在許多方面這是十分浪費的，但是在ASP可以接受。但是在Visual Basic中，當 <br />可能創建更有效的代碼時，變量就要被定義類型。這個程序很簡單，只需在聲明之後加上&quot;as <br />[data_type]&quot; ，這時它就不再是一個簡單的variant了。 <br /><br />比如說，現在有一個變量是一個字符串。打開一個ASP頁然後鍵入&quot;Dim strSession as String&quot;。然後 <br />預覽這個頁面，就會得到一個小小的驚喜。 <br /><br />Microsoft VBScript compilation error '800a0401' <br /><br />Expected end of statement <br /><br />/icu/temp.asp, line 3 <br /><br />Dim strSession as String <br /><br />---------------^ <br /><br />所以，如何作到不對ASP代碼造成威脅而準備Visual Basic 的變量？我不能確定對此如何評價。有 <br />一種方式是在變量聲明之後使用註釋標記。要注意這不僅在將代碼移植到VB時有幫助，當有別 <br />的公司提供高薪挖你走的時候，這還有助於別人理解你的代碼。以下是在ASP版本2中用註釋標記 <br />聲明變量的三種途徑： <br /><br />Private strString 'as String <br />Dim intInteger 'as Integer <br />Public bolBoolean 'as Boolean <br /><br />這種數據類型的定義技巧還適用於你在ASP應用程序中使用的任何函數。（請看下面部分子程序和函數）。 <br /><br />Private Function(strString, intInteger) 'as Boolean <br /><br />當我敲入我的ASP代碼時，也在其中貫穿了這些註釋。這也許不適合你，也許你在處理一些舊代碼， <br />在移植代碼之後，你可以使用Visual Basic 的搜索和替換功能來增加數據類型。這樣更有意義，因為 <br />在函數和子程序中不能註釋變量。代碼越是程序話，變量數據類型註釋就越少。 <br /><br />關於Visual Basic數據類型的更多信息，可以參看MSDN 有關數據類型的在線文章。 </p>
<p>使用子程序和函數 <br />作 者 : 青蘋果電腦工作室 <br /><br /><br />一個快速回答的問題：為什麼關於ASP的書中，討論使用子程序和函數的代碼的那麼少？ <br /><br />雖然一行一行地寫ASP代碼要更加簡單，但是以程序的形式來編碼卻有許多益處。 <br /><br />首先，非程序化的代碼不容易移植到Visual Basic。也許目前你沒有這個計劃，但是總有一天你會為了 <br />其性能或可擴展性而將一些代碼移植到組件中。 <br /><br />其次是程序是運行得更快。對ASP性能的最大消耗是上下文轉換，每次從ASP代碼區&lt; % % &gt; 移到無格式的 <br />HTML時都會發生。因為你不會在程序內部編碼一個上下文轉換，就不諱感覺到這種消耗。另外，ASP的 <br />緩衝器也顯示當子程序用程序化代碼點擊頁面時會有很大的不同。這裡是使用程序化代碼的ASP應用程序 <br />&quot;Hello World&quot; 的必須部分： <br /><br />Private Sub Main() <br />Response.Write &quot;Hello World!&quot; <br />End Sub <br /><br />Call Main <br /><br />為了完整起見，我在程序中包含了一個上下文轉換的小例子。如果你試驗這個代碼，它會運行，但是請 <br />不要在你自己的應用程序內部這樣做。 <br /><br />&lt; %@ Language=VBScript % &gt; <br />&lt; % <br />Private Sub DoStuff() <br />% &gt; <br />This is &lt; b &gt; HTML Text! &lt; /b &gt; <br />&lt; % <br />End Sub <br />% &gt; <br />&lt; HTML &gt; <br />&lt; HEAD &gt; <br />&lt; META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot; &gt; <br />&lt; /HEAD &gt; <br />&lt; BODY &gt; <br />&lt; P &gt;&lt; % Call DoStuff % &gt;&lt; /P &gt; <br />&lt; /BODY &gt; <br />&lt; /HTML &gt; <br /><br />程序化的代碼還有一些其它益處。首先你會發現再利用包含在程序中的代碼部分更加容易。其次，要 <br />實現同樣的目的所需要的代碼行更少。第三，你將要開始開發一個大的可再利用代碼庫。開始時它的 <br />形式是.inc 文件，最後你自己的普通COM組件看起來就像Jeff Gordon（著名賽車選手）一樣棒。 <br /><br />移植你的代碼 <br /><br />有幾件事與從VBScript向Visual Basic移植代碼一樣簡單。一般來說，你需要移走代碼並增加數據類型。 <br />有時，也可以在Visual Basic中應用一些更有效的算法，但是必須先保證代碼可以正常工作。 <br /><br />在我們這個應用程序舉例中，將要移植一些簡單的代碼到兩個Visual Basic COM 組件中。將一些HTML <br />表格格式拖到表述類中，將ADO 對像代碼拖到包裹了ADO 的數據存取類中。通過將這兩個類都放入 <br />ActiveX DLL 工程文件中可以使工程文件稍稍簡單化。在實際工作中，可以為每一層創建單獨的工程 <br />文件，但是這個工程文件要在一個DLL中表明思路。如果你想糾正這種情況，就將數據存取類移到另一個 <br />工程文件中並作為一個DLL編譯。必須在表述要應用它的DLL工程文件中增加對這個新DLL的引用。 <br /><br />在這個樣本工程文件中使用的數據庫是一個Northwind 數據庫，它與Visual Basic包含在一起。在這個 <br />樣本工程文件的ZIP 文件中，我為那些沒有安裝Visual Basic的人做了這個文件的一個表格的版本。樣本 <br />工程文件中還包含一個與ASP代碼一起使用的編譯過的DLL。 <br /><br />ASP頁面 <br />作 者 : 青蘋果電腦工作室 <br /><br />這個例子中的第一站是ASP頁。這個ASP頁用ADO與Northwind 數據庫連接。為了保持良好的編碼習慣，我 <br />使用了Option Explicit 並明確地聲明了所有變量。這個ASP頁的第一個草稿使用了內聯代碼。 <br /><br />&lt; % @ LANGUAGE=VBScript % &gt; <br />&lt; % <br />'Example of Inline code <br />Option Explicit <br /><br />'Declare variables <br />Dim oConn <br />Dim orS <br />Dim ConnectionString <br />Dim x <br /><br />ConnectionString = &quot;DSN=Northwind;&quot; <br /><br />Set oConn = Server.CreateObject(&quot;ADODB.Connection&quot;) <br />oConn.Open ConnectionString <br /><br />Set orS = Server.CreateObject(&quot;ADODB.Recordset&quot;) <br /><br />'Set variables <br />oRS.ActiveConnection = oConn <br />oRS.Source = &quot;Select * from Products&quot; <br />oRS.Open <br />% &gt; <br />&lt; html &gt; <br />&lt; head &gt; <br />&lt; meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot; &gt; <br />&lt; title &gt;New Page 1&lt; /title &gt; <br />&lt; /head &gt; <br />&lt; body &gt; <br />&lt; h1 &gt;Products&lt; /h1 &gt; <br />&lt; table cellspacing=&quot;2&quot; cellpadding=&quot;5&quot; &gt; <br />&lt; tr bgcolor=&quot;#FF6666&quot; &gt; <br />&lt; th &gt;Product Name&lt; /th &gt; <br />&lt; th &gt;Quantity Per Unitr&lt; /th &gt; <br />&lt; th &gt;Price&lt; /th &gt; <br />&lt; /tr &gt; <br />&lt; % <br />Do until orS.EOF <br />If x = 1 then <br />x = 0 <br />% &gt; <br />&lt; tr bgcolor=&quot;#ffcccc&quot; &gt; <br />&lt; % else % &gt; <br />&lt; tr &gt; <br />&lt; % <br />x = 1 <br />end if <br />% &gt; <br />&lt; td &gt;&lt; %=oRS(&quot;ProductName&quot;)% &gt;&lt; /td &gt; <br />&lt; td &gt;&lt; %=oRS(&quot;QuantityPerUnit&quot;)% &gt;&lt; /td &gt; <br />&lt; td &gt;&lt; %=oRS(&quot;UnitPrice&quot;)% &gt;&lt; /td &gt; <br />&lt; /tr &gt; <br />&lt; % <br />oRS.MoveNext <br />Loop <br />% &gt; <br />&lt; /table &gt; <br />&lt; /body &gt; <br />&lt; /html &gt; <br />&lt; % <br />'Destroy objects <br />Set orS = Nothing <br />Set oConn = Nothing <br />% &gt; <br /></p>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.kidbook.com.tw/asaprogramer/article.asp?id=20" /> 
	  <id>http://blog.kidbook.com.tw/asaprogramer/default.asp?id=20</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[ASP中實用的廣告交替組件]]></title>
	  <author>
		 <name>FindSome</name>
		 <uri>http://blog.kidbook.com.tw/asaprogramer/</uri>
		 <email>Findsome@mail.imagery.com.tw</email>
	  </author>
	  <category term="" scheme="http://blog.kidbook.com.tw/asaprogramer/default.asp?cateID=7" label="ASP" /> 
	  <updated>2007-11-12T10:57:22+08:00</updated>
	  <published>2007-11-12T10:57:22+08:00</published>
		  <summary type="html"><![CDATA[ASP中實用的廣告交替組件 <br />2000-06-14‧ wodeail‧CPCW <br /><br />　　你是不是經常在網上看到一些公司的廣告，並且他們能不停的變換各種廣告內容，這就是運用ASP中的廣告交替組件，使用廣告交替組件交替廣告圖標可以更好的發佈你的廣告和服務的推廣，更容易使別人接受你的廣告，並能簡單地實現交替顯示圖像。 <br /><br />(一).廣告交替組件的使用方法和具體屬性： <br /><br />1).GetAdvertisement方法 <br /><br />　　在這裡Server.CreateObject方法用於廣告交替的例子:Set ad=Server.CreateObject(&quot;MSWC.AdTotator&quot;),這裡Set命令用於和Server.Create.CreateObject 標誌符,聯合來創建一個MSWC.AdRotator對象的引用.廣告交替組件有一個方法:GetAdvertisement方法.GetAdvertisement方法管理和從調度文件檢取信息,當GetAdvertisement方法從一個新的頁面請求或從一個頁面更新的請求被調用時,GetAdvertisement方法瀏覽調度文件,以顯示下一個廣告圖案,GetAdvertisement方法的語法為:GetAdvertisement(&quot;filepath&quot;),filepath為調度文件的虛擬路徑. <br /><br />2).廣告交替組件要求的文件 <br /><br />　　Rotation schedule文件用於管理顯示頻率或顯示標題的文件(也就是廣告交替調度文件);Redirection文件為其重定向網址. <br /><br />3).廣告交替調度文件的具體方法屬性 <br /><br />　　這個文件用來管理廣告交替組件中廣告顯示的頻率和具體屬性,其具體方法見下表: <br /><br />名字 描述 作用範圍 <br /><br />Redirect(URL)為提交瀏覽器缺省位置 所有在交替調度中的圖像 所有圖像 <br /><br />width(填入要顯示圖像的具體大小) 設定圖像的像素寬度 所有圖像 <br /><br />height(像素值) 設定圖像的像素高度 所有圖像 <br /><br />border(表格寬度) 設定圖像邊框寬度 所有圖像 <br /><br />* 用以分隔具體顯示內容 所有圖像 <br /><br />AdUL 設定圖片地址 單一圖像 <br /><br />AdHomePageURL 設定廣告鏈接地址 單一圖像 <br /><br />Text 設定廣告文字顯示 單一圖像 <br /><br />Impresseions 設定廣告圖片顯示時間比 單一圖像 <br /><br />具體使用例子請看下例 <br /><br />4).重定向文件 <br /><br />　　　重定向文件(redirection file)將使瀏覽器指向目的地址,這裡的地址是在調度文件裡面確定的.這個重定向文件不僅用於將請求客戶指向被請求廣告,而且儲存各種關於請求客戶的信息,比如瀏覽器的類型和IP地址.在這裡用response.redirect方法將瀏覽器導向調度文件中指定的地址,如response.redirect(request.querystring(&quot;myAdUrl&quot;)),另外你可以使用各種分析代碼或頁面記數器組件來確定重定向文件的點擊數目. <br /><br />5).廣告交替屬性 <br /><br />名字 語法 描述 <br /><br />Border boarder(size),size用整數 設定廣告邊框寬度 <br /><br />表示邊框厚度 <br /><br />Clickable Clickable(value),value是 設定廣告交替標題是否是一個超級鏈接或圖像 <br /><br />true或false <br /><br />TargetFrame TargetFrame(frame),frame 設定目標的名字以及顯示標題 <br /><br />是一個html框的名字(如 <br /><br />_top,_parent等) <br /><br />　　這裡如果Clickable值設為真,則顯示一個超級聯接的標題.如果值為假,則只顯示標題並取消標 <br />題的超級聯接. <br /><br /><br />(二).具體使用示例： <br /><br />1).下面代碼可以放在你網頁需要加入廣告欄的地方 <br /><br />&lt; <br /><br />dim AD,adrot <br /><br />AD=&quot;adr.txt&quot; <br /><br />set adr=server.createobject(&quot;MSWC.ADROTATOR&quot;) <br /><br />adr.targetframe=&quot;target=&quot;&quot;adframe&quot;&quot;&quot; <br /><br />『讀取調度文件adr.txt <br /><br />response.write adr.GetAdvertisement(AD) <br /><br />&gt; <br /><br />2).下面是廣告調度文件adrot.txt，它表示了能所顯示圖像的屬性。 <br /><br />』redirect選項聲明了一個轉移地址的文件，這個文件用於指定用戶到目標的路徑。 <br /><br />redirect goto.asp <br /><br />』定義廣告圖像的大小和邊框屬性 <br /><br />width 468 <br /><br />height 60 <br /><br />border 0 <br /><br />* <br /><br />』指定圖片地址、鏈接地址和提示內容以及顯示的時間(這裡時間顯示比為50)。 <br /><br />http://www.yesky.com/logo.gif <br /><br />http://www.yesky.com <br /><br />天極網 <br /><br />50 <br /><br />redirect goto.asp <br /><br />border 0 <br /><br />* <br /><br />http://localhost/logo.gif <br /><br />http://aasp.yeah.net <br /><br />ASP動網先鋒 <br /><br />50 <br /><br />redirect goto.asp <br /><br />border 0 <br /><br />』同樣的可以用*號分隔不同的圖片地址和鏈接地址以實現廣告交替效果。 <br /><br />3).轉移地址的ASP文件goto.asp，是一個用於指定用戶到適合的URL(用戶路由表)參數路線的ASP文件。 <br /><br />&lt; <br /><br />&lt;@LANGUAGE=&quot;VBSCRIPT&quot;&gt; <br /><br />Response.AppendToLog Request.QueryString(&quot;url&quot;) <br /><br />Response.Redirect Request.QueryString(&quot;url&quot;) <br /><br />&gt; <br /><br />　　這個轉移地址文件被看作是一個記數裝置，用於跟蹤標記的效用，還提供了標記被點擊的次數。它使用request.redirect方法來重定向瀏覽器到指定的URL路線。 <br /><br /><br />　　好了，現在一個簡單的具有廣告自動輪換功能的廣告發佈系統就完成了，利用它可以在自己的主頁上自動輪顯原來定義好的廣告內容和圖片鏈接，如果需要還可以和別人交換網站的廣告內容，這樣一個簡單實用的程序你難道不想試試嗎？ <br />]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.kidbook.com.tw/asaprogramer/article.asp?id=19" /> 
	  <id>http://blog.kidbook.com.tw/asaprogramer/default.asp?id=19</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[如何在Web頁面中集成文件上傳功能]]></title>
	  <author>
		 <name>FindSome</name>
		 <uri>http://blog.kidbook.com.tw/asaprogramer/</uri>
		 <email>Findsome@mail.imagery.com.tw</email>
	  </author>
	  <category term="" scheme="http://blog.kidbook.com.tw/asaprogramer/default.asp?cateID=7" label="ASP" /> 
	  <updated>2007-11-12T10:41:59+08:00</updated>
	  <published>2007-11-12T10:41:59+08:00</published>
		  <summary type="html"><![CDATA[　　當前，個人主頁製作非常流行。當用戶開發好自己的頁面時，需要將文件傳輸到服務器上，解決這個問題的方法之一 <br />是運行FTP服務器並將每個用戶的FTP默認目錄設為用戶的Web主目錄，這樣用戶就能運行FTP客戶程序並上傳文件到指定的 <br />Web目錄。由於Windows NT 和 Windows98均不提供直接的基於窗口形式的FTP客戶程序，用戶必須懂得如何使用基於命令行 <br />的FTP客戶，或掌握一種新的基於窗口形式的FTP客戶程序。因此，這種解決方案僅對熟悉FTP且富有經驗的用戶來說是可行 <br />的。 如果我們能把文件上傳功能與Web集成，使用戶僅用Web瀏覽器就能完成上傳任務，這對於他們來說將是非常方便的。 <br />下面就結合筆者的實踐經驗對這一方案作一簡要介紹。 <br />　　本方案的軟件配置如下：客戶機操作系統為 Windows98 ； 服務器操作系統為Windows NT Server；Web服務器為 <br />IIS4.0。為使IIS能夠接收上傳的文件， 還必須安裝Posting Acceptor組件，該組件位於NT 4.0 Option Pack 的 Site <br />Server Express中。Posting Acceptor組件的ISAPI擴展函數CPSHOST.DLL直接處理文件上傳，目的URL被映射、解析為服務 <br />器上的物理磁盤位置。 <br />具體應用見如下網頁代碼： <br /><br /><br /><br />&lt;% Response.Buffer = TRUE %&gt; <br />&lt;% if (Len(Request.ServerVariables(&quot;LOGON_USER&quot;)) = 0 ) then %&gt; <br />&lt;% Response.Status = &quot;401 Unauthorized&quot; %&gt; <br />&lt;HTML&gt;&lt;BODY&gt;&lt;B&gt;錯誤: 拒絕訪問.&lt;/B&gt;&lt;P&gt;&lt;/BODY&gt;&lt;/HTML&gt; <br />&lt;% else %&gt; <br />&lt;html&gt; <br />&lt;head&gt; <br />&lt;title&gt;上傳文件&lt;/title&gt; <br />&lt;/head&gt; <br />&lt;body&gt; <br /><br />&lt;h1 align=&quot;center&quot;&gt;上傳文件&lt;/h1&gt; <br /><br />&lt;form method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; <br />action=&quot;http://&lt;%= Request.ServerVariables(&quot;SERVER_NAME&quot;) %&gt; <br />/myweb/cpshost.dll?PUBLISH&quot;&gt; <br />&lt;input name=&quot;TargetURL&quot; type=&quot;hidden&quot; value=&quot;http://&lt;%= <br />Request.ServerVariables(&quot;SERVER_NAME&quot;) %&gt;/myweb/&lt;%= <br />Request.ServerVariables(&quot;LOGON_USER&quot;) %&gt;&quot; <br />&gt; <br />請選擇要上傳的文件: &lt;input name=&quot;my_file&quot; type=&quot;file&quot;&gt;&lt;br&gt; <br />請選擇要上傳的文件: &lt;input name=&quot;my_file&quot; type=&quot;file&quot;&gt;&lt;br&gt; <br />請選擇要上傳的文件: &lt;input name=&quot;my_file&quot; type=&quot;file&quot;&gt;&lt;br&gt; <br />&lt;br&gt; <br />&lt;input type=&quot;submit&quot; name=&quot;cmdup&quot; value=&quot;上 傳&quot;&gt; <br />&lt;/form&gt; <br />&lt;/body&gt; <br />&lt;/html&gt; <br />&lt;% end if %&gt; <br /><br /><br /><br />　　上述代碼以ASP文件的形式存放在Web網站宿主目錄下myweb目錄中， 用戶只需用瀏覽器請求該文件即可。 <br />　　需要注意的幾點是： <br />　　□Request.ServerVariables(&quot;LOGON_USER&quot;)返回登錄到Windows NT域的用戶名，在本例中，如果用戶名為空，則顯示 <br />拒絕訪問頁面；不為空，才顯示正常上傳頁面。 <br />　　□在安裝Posting Acceptor組件後，CPSHOST.DLL文件位於Web服務器宿主目錄下scripts目錄中，可以把該文件拷貝到 <br />自己的目錄中使用。 <br />　　□在表單中，enctype=&quot;multipart/form-data&quot; 這一項不能少，否則不能正常上傳。 <br />　　□表單控件TargetURL的名稱(name屬性)不能變。type=&quot;hidden&quot;使該控件在頁面中不顯示。value屬性確定上傳文件在 <br />服務器中存放的路徑， 可以根據實際情況調整。在本例中，文件上傳路徑是myweb目錄(也就是本ASP文件和CPSHOST.DLL文 <br />件存放目錄)下與登錄用戶名同名的子目錄，並且該目錄權限設為可寫。 <br />　　□my_file控件類型為&quot;file&quot;，在瀏覽器中顯示的是一個文本框後帶一個&quot;瀏覽&quot;按鈕。當用戶單擊&quot;瀏覽&quot;按鈕時，將彈 <br />出一個標準的選擇文件對話框，供用戶選擇要上傳的文件。可以根據實際需要增減my_file控件的個數。 <br />]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.kidbook.com.tw/asaprogramer/article.asp?id=17" /> 
	  <id>http://blog.kidbook.com.tw/asaprogramer/default.asp?id=17</id>
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[純ASP上傳圖像文件到數據庫的最佳例子]]></title>
	  <author>
		 <name>FindSome</name>
		 <uri>http://blog.kidbook.com.tw/asaprogramer/</uri>
		 <email>Findsome@mail.imagery.com.tw</email>
	  </author>
	  <category term="" scheme="http://blog.kidbook.com.tw/asaprogramer/default.asp?cateID=7" label="ASP" /> 
	  <updated>2007-11-12T10:38:24+08:00</updated>
	  <published>2007-11-12T10:38:24+08:00</published>
		  <summary type="html"><![CDATA[<p>IAmTrue 發表於2000-11-2 7:56:49 ASP地帶 </p>
<p><br />getfile.htm <br />------------------------- <br />&lt;html&gt; <br /><br />&lt;head&gt; <br />&lt;title&gt;保存圖片到數據庫&lt;/title&gt; <br />&lt;/head&gt; <br /><br />&lt;body&gt; <br />&lt;b&gt; <br /><br />&lt;p&gt;&lt;/b&gt;你可以找個圖片試試，保存完畢後會有提示&lt;/p&gt; <br /><br />&lt;form METHOD=&quot;POST&quot; ENCTYPE=&quot;multipart/form-data&quot; ACTION=&quot;savetodb.asp&quot;&gt; <br />&lt;p&gt;Email : &lt;input NAME=&quot;email&quot; VALUE=&quot;wangcq@sina.com&quot; size=&quot;20&quot;&gt;&lt;br&gt; <br />Picture : &lt;input TYPE=&quot;file&quot; NAME=&quot;blob&quot;&gt;&lt;br&gt; <br />&lt;input TYPE=&quot;submit&quot; NAME=&quot;Enter&quot;&gt; &lt;/p&gt; <br />&lt;/form&gt; <br />&lt;/body&gt; <br />&lt;/html&gt; <br /><br />savetodb.asp <br />---------------------------------- <br />&lt;% <br /><br />Response.Buffer = TRUE <br />Response.Clear <br />byteCount = Request.TotalBytes <br /><br />RequestBin = Request.BinaryRead(byteCount) <br />Dim UploadRequest <br />Set UploadRequest = CreateObject(&quot;Scripting.Dictionary&quot;) <br /><br />BuildUploadRequest RequestBin <br /><br />email = UploadRequest.Item(&quot;email&quot;).Item(&quot;Value&quot;) <br /><br />contentType = UploadRequest.Item(&quot;blob&quot;).Item(&quot;ContentType&quot;) <br />filepathname = UploadRequest.Item(&quot;blob&quot;).Item(&quot;FileName&quot;) <br />filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,&quot;\&quot;)) <br />picture = UploadRequest.Item(&quot;blob&quot;).Item(&quot;Value&quot;) <br /><br />'Response.ContentType = contentType <br />'Response.binaryWrite picture <br /><br />set objCn = server.createobject(&quot;adodb.connection&quot;) <br />set objRst = server.createobject(&quot;adodb.recordset&quot;) <br />objCn.Open &quot;upload&quot; <br />objrst.Open &quot;pic&quot;, objcn, 1,3,2 <br />objrst.addnew <br />objrst.fields(&quot;filename&quot;)=filename <br />objrst.fields(&quot;type&quot;)=&quot;gif&quot; <br /><br />objrst.fields(&quot;what&quot;).appendchunk picture <br />objrst.update <br />response.write &quot;&lt;a href=showpic.asp?id=&quot; &amp; objrst(&quot;id&quot;) &amp; &quot;&gt;第&quot; &amp; objrst(&quot;id&quot;) &amp; &quot;個圖片。&lt;/a&gt;&quot; <br />objrst.close <br /><br />objCn.close <br />set objrst=nothing <br />set objcn = nothing <br />%&gt; <br />&lt;!--#include file=&quot;upload.asp&quot;--&gt; <br /><br />showpic.asp <br />---------------------------------------- <br />&lt;% <br />set objCn = server.createobject(&quot;adodb.connection&quot;) <br />set objRst = server.createobject(&quot;adodb.recordset&quot;) <br />objCn.Open &quot;upload&quot; <br />objrst.Open &quot;select what from pic where id=&quot; &amp; request(&quot;id&quot;), objcn <br /><br />if not objrst.eof then <br />response.binarywrite objrst(&quot;what&quot;) <br />end if <br /><br />objrst.close <br />objCn.close <br />set objrst=nothing <br />set objcn = nothing <br />%&gt; <br /><br /><br />upload.asp <br />------------------------------------------- <br />&lt;% <br />Sub BuildUploadRequest(RequestBin) <br />'Get the boundary <br />PosBeg = 1 <br />PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13))) <br />boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg) <br />boundaryPos = InstrB(1,RequestBin,boundary) <br />'Get all data inside the boundaries <br />Do until (boundaryPos=InstrB(RequestBin,boundary &amp; getByteString(&quot;--&quot;))) <br />'Members variable of objects are put in a dictionary object <br />Dim UploadControl <br />Set UploadControl = CreateObject(&quot;Scripting.Dictionary&quot;) <br />'Get an object name <br />Pos = InstrB(BoundaryPos,RequestBin,getByteString(&quot;Content-Disposition&quot;)) <br />Pos = InstrB(Pos,RequestBin,getByteString(&quot;name=&quot;)) <br />PosBeg = Pos+6 <br />PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34))) <br />Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) <br />PosFile = InstrB(BoundaryPos,RequestBin,getByteString(&quot;filename=&quot;)) <br />PosBound = InstrB(PosEnd,RequestBin,boundary) <br />'Test if object is of file type <br />If PosFile&lt;&gt;0 AND (PosFile&lt;PosBound) Then <br />'Get Filename, content-type and content of file <br />PosBeg = PosFile + 10 <br />PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34))) <br />FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) <br />'Add filename to dictionary object <br />UploadControl.Add &quot;FileName&quot;, FileName <br />Pos = InstrB(PosEnd,RequestBin,getByteString(&quot;Content-Type:&quot;)) <br />PosBeg = Pos+14 <br />PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13))) <br />'Add content-type to dictionary object <br />ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) <br />UploadControl.Add &quot;ContentType&quot;,ContentType <br />'Get content of object <br />PosBeg = PosEnd+4 <br />PosEnd = InstrB(PosBeg,RequestBin,boundary)-2 <br />Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg) <br />Else <br />'Get content of object <br />Pos = InstrB(Pos,RequestBin,getByteString(chr(13))) <br />PosBeg = Pos+4 <br />PosEnd = InstrB(PosBeg,RequestBin,boundary)-2 <br />Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) <br />End If <br />'Add content to dictionary object <br />UploadControl.Add &quot;Value&quot; , Value <br />'Add dictionary object to main dictionary <br />UploadRequest.Add name, UploadControl <br />'Loop to next object <br />BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary) <br />Loop <br /><br />End Sub <br /><br />'String to byte string conversion <br />Function getByteString(StringStr) <br />For i = 1 to Len(StringStr) <br />char = Mid(StringStr,i,1) <br />getByteString = getByteString &amp; chrB(AscB(char)) <br />Next <br />End Function <br /><br />'Byte string to string conversion <br />Function getString(StringBin) <br />getString =&quot;&quot; <br />For intCount = 1 to LenB(StringBin) <br />getString = getString &amp; chr(AscB(MidB(StringBin,intCount,1))) <br />Next <br />End Function <br />%&gt; <br /><br />test.mdb(dsn 名稱：upload) <br />---------------------------------------- <br />表pic: <br />id:自動加 <br />filename:文本 <br />type:文本 <br />what:ole <br /><br />----------------------------------------- <br />存成單個文件，放在一個目錄下，打開（必須用http://...）getfile.htm <br />上傳一個.gif或.jpg就可以顯示了。 <br />對於大文件在顯示程序(showpic.asp)中可能會用到循環和getchunk方法。自己去做。記住，由於ASP目前暫時不支持二進行制讀寫，只能存二進制到數據庫中。 <br />有什麼問題，請致電veryblue@chinese.com (IAmTrue) <br />----------------------------------------------------------------- <br /></p>]]></summary>
	  <link rel="alternate" type="text/html" href="http://blog.kidbook.com.tw/asaprogramer/article.asp?id=16" /> 
	  <id>http://blog.kidbook.com.tw/asaprogramer/default.asp?id=16</id>
  </entry>	
		
</feed>
