<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2893139382062216061</id><updated>2011-11-28T08:07:05.196+08:00</updated><category term='實用軟體'/><category term='Drupal'/><category term='Blogger設定'/><category term='Access'/><category term='程式語法'/><category term='Joomla'/><category term='Zen Cart'/><category term='SEO優化'/><category term='Linux Ubuntu'/><category term='Excel VBA'/><category term='Asp.Net'/><category term='ECSHOP'/><category term='生活記錄'/><category term='資訊新鮮事'/><category term='電腦疑難雜症'/><category term='Xampp'/><category term='網路管理'/><title type='text'>威筆記</title><subtitle type='html'>『威筆記』知識累積、經驗分享。分享是知識的累積、分享是加倍的喜悅。熱愛資訊、努力累積自我無形資產</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default?start-index=101&amp;max-results=100'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>118</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-6603930228775773909</id><published>2010-05-09T22:08:00.002+08:00</published><updated>2010-05-09T22:14:40.274+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='網路管理'/><title type='text'>ipconfig 指令參數說明</title><content type='html'>在Windows命令提示字元中(cmd)，&lt;strong&gt;ipconfig&lt;/strong&gt;是Windows系統的TCP/IP應用程式指令，其用途為顯示本機電腦的&lt;strong&gt;IP位址&lt;/strong&gt;與相關配置資訊。&lt;strong&gt;ipconfig&lt;/strong&gt;對於網路的故障排除有著重要的作用，其參數指令直覺且易用。&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;語法：&lt;/span&gt;&lt;br /&gt;ipconfig&amp;nbsp; [/參數]&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #ff8000;"&gt;參數說明：&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;/all&lt;/strong&gt;&lt;br /&gt;顯示網路卡的TCP/IP所有完整配置資訊。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;/renew &lt;/strong&gt;&lt;strong&gt;[adapter]&lt;/strong&gt;&lt;br /&gt;用於需重新配置DHCP的網路卡。(此參數只可用於設定為自動DHCP配置IP位址的環境下)&lt;/li&gt;&lt;li&gt;&lt;strong&gt;/release &lt;strong&gt;[adapter]&lt;/strong&gt;&lt;/strong&gt;&lt;br /&gt;要求DHCP釋放(丟棄)網路卡的IP位址。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;/displaydns&lt;/strong&gt;&lt;br /&gt;顯示DNS快取內容。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;/flushdns&lt;/strong&gt;&lt;br /&gt;重新刷新清理DNS快取。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;/registerdns&lt;/strong&gt;&lt;br /&gt;重新註冊(初始化)IP位址與DNS名稱。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;/showclassid &lt;strong&gt;[adapter]&lt;/strong&gt;&lt;/strong&gt;&lt;br /&gt;顯示網路卡的DHCP類別ID。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;/setclassid &lt;strong&gt;[adapter]&lt;/strong&gt;&lt;/strong&gt;&lt;br /&gt;配置網路卡的DHCP類別ID。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;/?&lt;/strong&gt;&lt;br /&gt;顯示ipconfig的參數說明。&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-6603930228775773909?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/6603930228775773909/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/05/ipconfig.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6603930228775773909'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6603930228775773909'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/05/ipconfig.html' title='ipconfig 指令參數說明'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-191091073685822141</id><published>2010-05-03T21:57:00.001+08:00</published><updated>2010-05-03T21:58:54.359+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>讓Chrome瀏覽器支援MaintainScrollPositionOnPostback屬性</title><content type='html'>&lt;p&gt;&lt;a href="http://msdn.microsoft.com/zh-tw/library/system.web.ui.page.maintainscrollpositiononpostback%28VS.80%29.aspx" target="_blank"&gt;&lt;strong&gt;MaintainScrollPositionOnPostback&lt;/strong&gt;&lt;/a&gt;主要功能是在Asp.Net的Page中取得或設定值，指出在回傳後是否將使用者返回用戶端瀏覽器中的相同位置。簡單的說就是讓頁面在PostBack後還能保持頁面位置。&lt;br&gt;&lt;br&gt;即使我們在Page中設定了MaintainScrollPositionOnPostback為True，但在最近市佔率越來越高的&lt;a href="http://www.google.com/chrome/index.html?hl=zh-TW&amp;amp;brand=CHMA&amp;amp;utm_campaign=zh_hk&amp;amp;utm_source=zh-TW-ha-apac-tw-bk&amp;amp;utm_medium=ha" target="_blank"&gt;Chrome&lt;/a&gt;這個&lt;strong&gt;&lt;/strong&gt;以速度快著名的Goolge瀏覽器卻是失效了。&lt;br&gt;&lt;br&gt;自己在遇這個問題後，在Google找到此站提供的方式解決了我的問題：&lt;br&gt;&lt;a href="http://blog.uni2.tw/post/2009/07/17/e8ae93Chromee7808fe8a6bde599a8e694afe68fb4AspNete79a84MaintainScrollPositionOnPostback.aspx" target="_blank"&gt;讓Chrome瀏覽器支援Asp.Net的MaintainScrollPositionOnPostback&lt;/a&gt;&lt;br&gt;但此網頁已失連許久，也在Google找不到相同提供解決方法的網頁(也許有，我沒找到)。因此特地在此記錄並提供給有遇到同樣問題的朋友一個解決的辦法。&lt;br&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#0000ff"&gt;解決方法：&lt;/font&gt;&lt;/strong&gt;&lt;br&gt;首先在Asp.Net中新增一個瀏覽器定義檔，我們要使用這個定義檔來根據不同瀏覽器設定不同運行環境參數。&lt;br&gt;&lt;a href="http://lh5.ggpht.com/_2sQfBxJU9mI/S97WKYaZkeI/AAAAAAAAMC4/bq0FluxrsA4/s1600-h/2010-05-03_213205%5B4%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-05-03_213205" border="0" alt="2010-05-03_213205" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S97WLl8bfRI/AAAAAAAAMC8/myelQix8otU/2010-05-03_213205_thumb%5B2%5D.jpg?imgmax=800" width="504" height="337"&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;.browser建立後預設會放在App_Browesers資料夾中。打開.browser後將以下程式碼直接複製貼上：&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;browsers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;browser&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Safari3"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;parentID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Safari1Plus"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;identification&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;userAgent&lt;/span&gt; &lt;span style="color: #ff0000"&gt;match&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Safari/\d+\.\d+"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;identification&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;capture&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;userAgent&lt;/span&gt; &lt;span style="color: #ff0000"&gt;match&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Version/(?'version'\d+\.\d+)"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;capture&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;capabilities&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;capability&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="browser"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Safari3"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;capability&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="version"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="${version}"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;capabilities&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;controlAdapters&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;adapter&lt;/span&gt; &lt;span style="color: #ff0000"&gt;controlType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="System.Web.UI.WebControls.Menu"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                     &lt;span style="color: #ff0000"&gt;adapterType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=""&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;controlAdapters&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;browser&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;browser&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="GoogleChrome"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;parentID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Safari3"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;identification&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;userAgent&lt;/span&gt; &lt;span style="color: #ff0000"&gt;match&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Chrome/(?'version'\d+\.\d+)"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;identification&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;capabilities&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;capability&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="browser"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Googlebot"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;capability&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="supportsMaintainScrollPositionOnPostback"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="true"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;capabilities&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;browser&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;browsers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br&gt;上面這段程式碼原本主要的用途是用來解決Asp.Net中的Menu控制項，在Chrom與Safari瀏覽器下顯示不完全的問題。詳情可以參考：&lt;a href="http://www.cnblogs.com/Whikiey/archive/2009/03/03/1402463.html" target="_blank"&gt;最簡單的方法，讓 ASP.NET Menu 控件在 Google Chrome 瀏覽器上正常顯示&lt;/a&gt;&lt;br&gt;&lt;br&gt;按照原作者的方法直接在GoogleChrome的定義中加入這一行程式碼：&lt;br&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;&amp;lt;capability name="supportsMaintainScrollPositionOnPostback" value="true" /&amp;gt;&lt;br&gt;&lt;/strong&gt;&lt;font color="#000000"&gt;&lt;br&gt;如此即可解決MaintainScrollPositionOnPostback在Chrome瀏覽器失效的問題了，可謂一舉兩得。&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-191091073685822141?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/191091073685822141/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/05/chromemaintainscrollpositiononpostback.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/191091073685822141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/191091073685822141'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/05/chromemaintainscrollpositiononpostback.html' title='讓Chrome瀏覽器支援MaintainScrollPositionOnPostback屬性'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_2sQfBxJU9mI/S97WLl8bfRI/AAAAAAAAMC8/myelQix8otU/s72-c/2010-05-03_213205_thumb%5B2%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-3058996984593503111</id><published>2010-05-03T21:09:00.001+08:00</published><updated>2010-05-03T21:09:26.112+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>解決FileUpload上傳超過4M大檔案時瀏覽器出現錯誤訊息</title><content type='html'>&lt;p&gt;在Asp.Net中若使用FileUpload控制項實作檔案上傳時，除了在上傳按鈕事件中可以使用FileUpload.PostedFile.ContentLength來取得檔案大小來限制使用者上傳檔案大小之外，另外一個我們都會遇到的必需去解決的課題，是在Asp.Net環境中系統預設了最大上傳容量為4M(4096KB)。因此若網站User在上傳的檔案超過4M瀏覽器就會出現錯誤訊息，而User殊不知是自己上傳了過大檔案導致，以為是系統故障了。&lt;br&gt;&lt;br&gt;Asp.Net會有此一限制，是為了能夠避免『&lt;a href="http://zh.wikipedia.org/zh-tw/%E5%88%86%E6%95%A3%E5%BC%8F%E9%98%BB%E6%96%B7%E6%9C%8D%E5%8B%99%E6%94%BB%E6%93%8A" target="_blank"&gt;分散式阻斷服務攻擊&lt;/a&gt;』(DDoS)，免去一些在不懂資安情況之下得到最小限度的保護措施。&lt;br&gt;&lt;br&gt;既然系統幫我們預設了最大上傳，當然爾我們也可以依照個人不同需求來調整這個預設值。設定的方法很簡單，我們只需在&lt;strong&gt;Web.Config&lt;/strong&gt;檔中指定&lt;/p&gt;&lt;a href="http://msdn.microsoft.com/zh-tw/library/e1f13641(VS.80).aspx" target="_blank"&gt;&lt;strong&gt;httpRuntime&lt;/strong&gt;&lt;/a&gt;項目的屬性即可。 &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;system.web&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;httpRuntime&lt;/span&gt; &lt;span style="color: #ff0000"&gt;executionTimeout&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;"1800"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;maxRequestLength&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="100000"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;system.web&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;&lt;br&gt;executionTimeout&lt;/b&gt;屬性：以秒為單位，代表網頁執行期間所需執行最大秒數(預設是90秒)，若網頁執行超過設定值時間會發生TimeOut的情況。&lt;br&gt;&lt;b&gt;maxRequestLength&lt;/b&gt;屬性：以KB為單位，指定輸入資料流緩衝臨界值的限制，也就是我們所需指定允許最大上傳容量設定值(預設值為4096KB)。&lt;br&gt;&lt;br&gt;&lt;font color="#808080"&gt;補充：&lt;br&gt;&lt;/font&gt;若需自訂超過檔案限制大小時瀏覽器出現錯誤時的頁面，可於Web.Config中設定&lt;a href="http://msdn.microsoft.com/zh-tw/library/h0hfz6fc(VS.80).aspx" target="_blank"&gt;customErrors&lt;/a&gt;項目，自行指定錯誤發生時所需顯示的頁面：&lt;br&gt;&amp;lt;customErrors mode="On" defaultRedirect="ErrorPage.aspx" /&amp;gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;更多內容可參考：&lt;br&gt;&lt;a href="http://blogs.msdn.com/jchiou/archive/2008/03/10/asp-net-4mb.aspx" target="_blank"&gt;ASP.NET 無法上載大型檔案(大於 4MB)&lt;/a&gt;&lt;br&gt;&lt;a href="http://blog.miniasp.com/?tag=/maxrequestlength" target="_blank"&gt;ASP.NET 當上傳檔案過大時任何回應瀏覽器的動作都無效&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-3058996984593503111?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/3058996984593503111/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/05/fileupload4m.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/3058996984593503111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/3058996984593503111'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/05/fileupload4m.html' title='解決FileUpload上傳超過4M大檔案時瀏覽器出現錯誤訊息'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-8802354782848626218</id><published>2010-04-29T22:07:00.001+08:00</published><updated>2010-04-29T22:07:02.113+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>[Tips] 在Asp.Net中替VB.Net一次多行註解</title><content type='html'>&lt;p&gt;使用VB.Net寫Asp.Net的人一定都知道要註解VB程式碼的方法，直接在要註解那行程式碼最前端加上 ' 號。&lt;br&gt;&lt;br&gt;使用C#可以使用 // 來註解單行，亦可使用 /*&amp;nbsp; */ 來包覆程式碼達到多行註解的功能。那VB如何使用多行註解？很抱歉…VB並不支援多行註解。雖然如此，VB的Programmers也無需過於擔心，若使用的開發軟體為Vistual Studio ，就不需要自己一行一行手動Key ' 號註解了。&lt;br&gt;&lt;br&gt;&lt;font color="#ff8000"&gt;&lt;strong&gt;VB.Net多行註解方法：&lt;br&gt;&lt;/strong&gt;&lt;/font&gt;&lt;font color="#000000"&gt;在Vistual Studio上方工具列可以找到如下圖『&lt;strong&gt;註解選取行&lt;/strong&gt;』的按鈕&lt;br&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S9mSWsx420I/AAAAAAAAMCI/ut_LsKLai20/s1600-h/2010-04-29_214952%5B4%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-04-29_214952" border="0" alt="2010-04-29_214952" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S9mSXWP_yAI/AAAAAAAAMCM/k9XgaXTL8UM/2010-04-29_214952_thumb%5B2%5D.jpg?imgmax=800" width="504" height="109"&gt;&lt;/a&gt; &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;br&gt;若沒找到，試著從&lt;strong&gt;檢視→工具列→文字編輯器&lt;/strong&gt;，將其工具列打開&lt;br&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S9mSYPyFbcI/AAAAAAAAMCQ/Hz6bgkSWLVo/s1600-h/2010-04-29_215106%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-04-29_215106" border="0" alt="2010-04-29_215106" src="http://lh3.ggpht.com/_2sQfBxJU9mI/S9mSZIlVToI/AAAAAAAAMCU/RJo8tt5v410/2010-04-29_215106_thumb%5B1%5D.jpg?imgmax=800" width="504" height="350"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;br&gt;OK!接著就是將欲註解的程式碼反白後，直接按下『&lt;strong&gt;註解選取行&lt;/strong&gt;』按鈕&lt;br&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S9mSZ4SPkZI/AAAAAAAAMCY/lRQxuw_L3eU/s1600-h/2010-04-29_215212%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-04-29_215212" border="0" alt="2010-04-29_215212" src="http://lh3.ggpht.com/_2sQfBxJU9mI/S9mSa5wmUwI/AAAAAAAAMCc/4zO4UB__S4E/2010-04-29_215212_thumb%5B1%5D.jpg?imgmax=800" width="504" height="300"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;br&gt;最後結果所有被反白的程式碼都加上了 ' 號註解了，非常容易又方便呀!&lt;br&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S9mSbtmnJxI/AAAAAAAAMCg/2OF2zZ6je2k/s1600-h/2010-04-29_215253%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-04-29_215253" border="0" alt="2010-04-29_215253" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S9mScl1OwII/AAAAAAAAMCk/aav2j4-MGnY/2010-04-29_215253_thumb%5B1%5D.jpg?imgmax=800" width="504" height="316"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;br&gt;取消多行註解的方式也一樣，反白程式碼後點擊『&lt;strong&gt;取消註解選取行&lt;/strong&gt;』按鈕即可。&lt;br&gt;&lt;a href="http://lh5.ggpht.com/_2sQfBxJU9mI/S9mSdd1SdOI/AAAAAAAAMCo/AKBN58v_A0c/s1600-h/2010-04-29_215334%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-04-29_215334" border="0" alt="2010-04-29_215334" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S9mSfEEmzYI/AAAAAAAAMCs/VmoT0-Wf5uw/2010-04-29_215334_thumb%5B1%5D.jpg?imgmax=800" width="504" height="164"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;br&gt;或想自己使用&lt;strong&gt;Alt+左鍵&lt;/strong&gt;選取區塊的方式將多行註解選取起來再按下Del鍵刪除也可，看個人習慣囉!&lt;br&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S9mSgFveTrI/AAAAAAAAMCw/AQAoZVqPTUE/s1600-h/2010-04-29_220336%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-04-29_220336" border="0" alt="2010-04-29_220336" src="http://lh3.ggpht.com/_2sQfBxJU9mI/S9mShVoEzoI/AAAAAAAAMC0/R2UnW8oY8qs/2010-04-29_220336_thumb%5B1%5D.jpg?imgmax=800" width="504" height="248"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-8802354782848626218?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/8802354782848626218/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/tips-aspnetvbnet.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8802354782848626218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8802354782848626218'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/tips-aspnetvbnet.html' title='[Tips] 在Asp.Net中替VB.Net一次多行註解'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_2sQfBxJU9mI/S9mSXWP_yAI/AAAAAAAAMCM/k9XgaXTL8UM/s72-c/2010-04-29_214952_thumb%5B2%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-6329712705059242374</id><published>2010-04-29T21:31:00.001+08:00</published><updated>2010-04-29T21:31:36.547+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>[Tips] 移除ViewState值的兩種寫法</title><content type='html'>&lt;p&gt;VB.Net寫法：&lt;br&gt;&lt;br&gt;1、將ViewState("Test")值移除&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font color="#0000ff"&gt;ViewState.Remove("Test")&lt;/font&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;or&lt;br&gt;&lt;br&gt;2、ViewState("Test")值設為Null&lt;br&gt;&lt;strong&gt;&lt;font color="#0000ff"&gt;ViewState("Test") = DBNull.Value&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-6329712705059242374?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/6329712705059242374/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/tips-viewstate.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6329712705059242374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6329712705059242374'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/tips-viewstate.html' title='[Tips] 移除ViewState值的兩種寫法'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-8975750497768352307</id><published>2010-04-28T21:39:00.002+08:00</published><updated>2010-04-28T21:40:08.907+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='資訊新鮮事'/><title type='text'>想做你的CODE：Vistual Studio 2010全球發佈會宣傳影片</title><content type='html'>『&lt;b&gt;想做你的CODE&lt;/b&gt;』：&lt;b&gt;更痛快地CODING，給愛更多好心情……&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Programer時最容易犯的毛病，除了CODING卻忽略身邊太多的事物，這挺符合Vistual Studio強調的快速開發。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="wlWriterEditableSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:c3bbaf46-ef83-4c80-a398-c74610c4c2e4" style="display: inline; float: none; margin: 0px; padding: 0px;"&gt;&lt;div id="99bda722-b388-4525-b36b-e4c1b1e21499" style="display: inline; margin: 0px; padding: 0px;"&gt;&lt;div&gt;&lt;a href="http://www.youtube.com/watch?v=0gliakvtTgs&amp;amp;hl=zh_TW&amp;amp;fs=1&amp;amp;" target="_new"&gt;&lt;img alt="" galleryimg="no" onload="var downlevelDiv = document.getElementById('99bda722-b388-4525-b36b-e4c1b1e21499'); downlevelDiv.innerHTML = &amp;quot;&amp;lt;div&amp;gt;&amp;lt;object width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;param name=\&amp;quot;movie\&amp;quot; value=\&amp;quot;http://www.youtube.com/v/0gliakvtTgs&amp;amp;hl=zh_TW&amp;amp;fs=1&amp;amp;&amp;amp;hl=en\&amp;quot;&amp;gt;&amp;lt;\/param&amp;gt;&amp;lt;embed src=\&amp;quot;http://www.youtube.com/v/0gliakvtTgs&amp;amp;hl=zh_TW&amp;amp;fs=1&amp;amp;&amp;amp;hl=en\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;\/embed&amp;gt;&amp;lt;\/object&amp;gt;&amp;lt;\/div&amp;gt;&amp;quot;;" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S9g6ht0jH2I/AAAAAAAAMCE/AuPEh2f-SpY/videof823711f3060%5B4%5D.jpg?imgmax=800" style="border-style: none;" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-8975750497768352307?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/8975750497768352307/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/codevistual-studio-2010.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8975750497768352307'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8975750497768352307'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/codevistual-studio-2010.html' title='想做你的CODE：Vistual Studio 2010全球發佈會宣傳影片'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_2sQfBxJU9mI/S9g6ht0jH2I/AAAAAAAAMCE/AuPEh2f-SpY/s72-c/videof823711f3060%5B4%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-7580507865702070782</id><published>2010-04-27T22:44:00.001+08:00</published><updated>2010-04-27T22:44:57.094+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>解決Asp.net網站佈署至國外虛擬主機日期格式不同的問題</title><content type='html'>&lt;p&gt;若您與我一樣使用的是國外虛擬主機運作Asp.Net網站，可能需要注意一下在不同語系的Server系統上，會產生不同日期格式的問題。由於國外虛擬主機用的是英文版的Windows Server，網站中若有使用到DateTime抓取系統時間也會自動顯示為國外的日期格式。&lt;br&gt;&lt;br&gt;雖然DateTime可加上ToString來自訂日期格式，如DateTime.ToString("yyyy/MM/dd HH:mm:ss")，但某些Asp.Net的extender也會跟著系統的語系顯示不同語系，如Ajax ControlToolKit 的CalendarExtender。&lt;br&gt;&lt;br&gt;要避免此問題最方便的方法是直接在&lt;strong&gt;Web.Config&lt;/strong&gt;檔案中指定網站程式預設語系為zh-Tw(中文)語系。&lt;br&gt;&lt;br&gt;&lt;font color="#ff8000"&gt;設定方法：&lt;/font&gt;&lt;br&gt;在Web.Config檔中加入&lt;br&gt;&amp;lt;system.web&amp;gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;&lt;font color="#0000ff"&gt;&amp;lt;globalization culture="zh-TW' /&amp;gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&amp;lt;/system.web&amp;gt;&lt;br&gt;&lt;br&gt;如此不管使用的運行的Server語系為何，網站都會以中文語系顯示了。&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-7580507865702070782?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/7580507865702070782/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/aspnet.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/7580507865702070782'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/7580507865702070782'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/aspnet.html' title='解決Asp.net網站佈署至國外虛擬主機日期格式不同的問題'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-6370073518173448616</id><published>2010-04-27T22:16:00.002+08:00</published><updated>2010-04-27T22:19:30.018+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>設定Html編輯器FreeTextBox在Enter換行時為&lt;br&gt;</title><content type='html'>最近在一個專案中使用了免費版的&lt;b&gt;&lt;a href="http://www.freetextbox.com/" target="_blank"&gt;FreeTextBox&lt;/a&gt;&lt;/b&gt;線上Html編輯器，發現的問題是在FreeTextBox編輯內容按下Enter鍵換行時，不同瀏覽器下的換行行距會有所不同。&lt;br /&gt;&lt;br /&gt;以下為各瀏覽器在FreeTextBox下Enter鍵預設輸出的語法：&lt;br /&gt;Firefox → &amp;lt;br&amp;gt;&lt;br /&gt;Chrome → &amp;lt;div&amp;gt;&lt;br /&gt;IE8 → &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;Opera → &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;&lt;br /&gt;顯然的IE8與Opera的&amp;lt;p&amp;gt;段落即為造成換行行距過大的問題所在。因不可能告知所有網站User要換行請使用Shift+Enter來產生&amp;lt;br&amp;gt;換行，我希望找到方法使得Enter預設值可由&amp;lt;p&amp;gt;段落改為使用&amp;lt;br&amp;gt;換行語法。&lt;br /&gt;&lt;br /&gt;在FreeTextBox中有個屬性值為&lt;span style="color: blue;"&gt;&lt;b&gt;BreakMode&lt;/b&gt;&lt;span style="color: black;"&gt;&lt;b&gt;，&lt;/b&gt;說明文件&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;對屬性解釋如下：&lt;/span&gt;&lt;br /&gt;&lt;span style="color: navy;"&gt;&lt;span style="color: green;"&gt;.BreakMode&lt;br /&gt;Sets&amp;nbsp;&amp;nbsp; what&amp;nbsp;&amp;nbsp; happens&amp;nbsp;&amp;nbsp; when&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; "Enter"&amp;nbsp;&amp;nbsp; key&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; pressed.&amp;nbsp;&amp;nbsp; Options&amp;nbsp;&amp;nbsp; are&amp;nbsp;&amp;nbsp; LineBreak&amp;nbsp;&amp;nbsp; (IE&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; Mozilla)&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; Paragraph&amp;nbsp;&amp;nbsp; (IE&amp;nbsp;&amp;nbsp; only)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;FreeTextBox的BreakMode預設值為Paragraph(段落)，因此只要設定&lt;b&gt;&lt;span style="color: red;"&gt;BreakMode="LineBreak" &lt;/span&gt;&lt;/b&gt;即可將預設&amp;lt;p&amp;gt;更改為&amp;lt;br&amp;gt;。&lt;br /&gt;&lt;br /&gt;根據說明文件可以得知設定LineBreak模式只能影響IE與FireFox瀏覽器，在Chrome及Opera是無效的，這點需要特別注意一下。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-6370073518173448616?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/6370073518173448616/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/htmlfreetextboxenter.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6370073518173448616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6370073518173448616'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/htmlfreetextboxenter.html' title='設定Html編輯器FreeTextBox在Enter換行時為&amp;lt;br&amp;gt;'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-3762060835848567629</id><published>2010-04-22T21:44:00.001+08:00</published><updated>2010-04-22T21:44:48.819+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>SqlDataSource設計模式中SelectCommand使用If…Else條件</title><content type='html'>&lt;p&gt;一般來說我們都會將使用codebehind的方式來指定SqlDataSource的SelectCommand內容。但在比較複雜的邏輯程式中不得已必須在設計模式中直接指定SelectCommand內容，又需要對某控制項來取值作為SQL中的Where條件時，我們可以使用T-SQL中的條件語法If…Else來實現。&lt;br&gt;&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;T-SQL If…Else 架構：&lt;/strong&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;If&amp;nbsp; 條件式&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Begin&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T-SQL語法&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End&lt;br&gt;Else&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Begin&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T-SQL語法&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;font color="#000000"&gt;Begin End是用來設定T-SQL程式碼範圍，若你的T-SQL語法超過一行請務必記得加上Begin End，否則你會發現就算寫了多行也只會執行第一行程式。最好是養成不管一行多行程式都用Begin….End包起來的好習慣。&lt;br&gt;&lt;br&gt;&lt;strong&gt;範例：&lt;/strong&gt;&lt;br&gt;在SqlDataSource的SelectCommand對DropDownList控制項取值，判斷DropDownList值是否為All來達成不同條件資料過濾。&lt;br&gt;&lt;br&gt;DropDownList內容：&lt;/font&gt;&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:DropDownList&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="DropDownList"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #ff0000"&gt;AppendDataBoundItems&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="True"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DataSourceID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Sort_SqlDataSource"&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #ff0000"&gt;DataTextField&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="分類項目"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DataValueField&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="分類編號"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:ListItem&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="All"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;請選擇&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:ListItem&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:DropDownList&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:SqlDataSource&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Sort_SqlDataSource"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #ff0000"&gt;ConnectionString&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="&amp;lt;%$ ConnectionStrings:TestConnectionString %&amp;gt;"&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #ff0000"&gt;SelectCommand&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="SELECT * FROM 分類"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:SqlDataSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;SqlDataSource SelectCommand內容：&lt;br&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:SqlDataSource&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="SqlDataSource"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #ff0000"&gt;ConnectionString&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="&amp;lt;%$ ConnectionStrings:TestConnectionString %&amp;gt;"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #ff0000"&gt;SelectCommand&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="if (@分類項目='All') begin Select * From 測試 end else begin Select * From 測試 Where 分類項目=@分類項目 end"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;SelectParameters&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:ControlParameter&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ControlID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="DropDownList"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="分類項目"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;PropertyName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="SelectedValue"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;SelectParameters&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:SqlDataSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-3762060835848567629?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/3762060835848567629/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/sqldatasourceselectcommandifelse.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/3762060835848567629'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/3762060835848567629'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/sqldatasourceselectcommandifelse.html' title='SqlDataSource設計模式中SelectCommand使用If…Else條件'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-365026771057909910</id><published>2010-04-15T20:37:00.001+08:00</published><updated>2010-04-15T20:37:18.042+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>[Ajax]CalendarExtender與TextBox的ReadOnly設為True取不到值的解決方法</title><content type='html'>&lt;p&gt;使用CalendarExtender控制項時通常一定會搭配TextBox控制項，且定會想將TexBox欄位設為唯讀來防止User自行輸入一些不符合資料庫欄位規格的日期格式。&lt;br&gt;&lt;br&gt;然而從Asp.Net 2.0開始若將TextBox設為ReadOnly後會發現，在PostBack後卻無法順利取得TextBox.Text值，這是Asp.Net 2.0後基於安全性考量而作的改變。&lt;br&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;解決方法：&lt;br&gt;&lt;/font&gt;&lt;font color="#000000"&gt;不在設計模式中設定TextBox的唯獨屬性，而在codebehind的Page_Load事件中使用&lt;a href="http://msdn.microsoft.com/zh-tw/library/system.web.ui.webcontrols.webcontrol.attributes%28VS.80%29.aspx"&gt;WebControl.Attributes&lt;/a&gt; 屬性動態加入唯獨屬性的設定。&lt;/font&gt;&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; Page_Load(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Load&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; IsPostBack &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;           TextBox.Attributes.Add(&lt;span style="color: #006080"&gt;"readonly"&lt;/span&gt;, &lt;span style="color: #006080"&gt;"true"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-365026771057909910?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/365026771057909910/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/ajaxcalendarextendertextboxreadonlytrue.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/365026771057909910'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/365026771057909910'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/ajaxcalendarextendertextboxreadonlytrue.html' title='[Ajax]CalendarExtender與TextBox的ReadOnly設為True取不到值的解決方法'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-2594619284010349837</id><published>2010-04-14T22:51:00.001+08:00</published><updated>2010-04-14T22:54:13.746+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>解決[Ajax]CalendarExtender彈出時被GridView或其它物件遮擋的問題</title><content type='html'>&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_2sQfBxJU9mI/S8XWZfEXUKI/AAAAAAAAMB0/OastlHbh764/s1600-h/2010-04-14_223340%5B4%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-04-14_223340" border="0" alt="2010-04-14_223340" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S8XWafRbHtI/AAAAAAAAMB4/dnB3U4cFIvM/2010-04-14_223340_thumb%5B2%5D.jpg?imgmax=800" width="504" height="195"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;br&gt;上圖的CalendarExtender日曆控制項彈出時被下方的GridView Header 的Div Css擋住了。我們必須使CalendarExtender能永遠顯示在畫面最頂端，&lt;br&gt;正常的情況應該如下圖：&lt;br&gt;&lt;br&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S8XWbhY80sI/AAAAAAAAMB8/Y3_19T8ltfQ/s1600-h/2010-04-14_223408%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-04-14_223408" border="0" alt="2010-04-14_223408" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S8XWck7WtbI/AAAAAAAAMCA/9dP_dxjA0N4/2010-04-14_223408_thumb%5B1%5D.jpg?imgmax=800" width="504" height="196"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;解決方法：&lt;/font&gt;&lt;br&gt;我們將寫一個Css並將其指定給CalendarExtender：&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ajaxtoolkit:calendarextender&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="CalendarExtender"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt; &lt;span style="color: #ff0000"&gt;TargetControlID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Date"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;PopupButtonID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Calendar_Image"&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #ff0000"&gt;Format&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="yyyy/MM/dd"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;FirstDayOfWeek&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Monday"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;CssClass&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="cssCalendar"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br&gt;CalendarExtender CSS內容中將月曆控制項指定z-index屬性。z-index是用來指定圖層的層數，例如z-index:1為最底層，z-index:2為第2層以此類推。&lt;br&gt;最重要的是需將此CSS 的z-index屬性寫在&lt;strong&gt;.ajax__calendar_container&lt;br&gt;&lt;/strong&gt;代表將整個CalendarExtender 容器的層數設為最頂層(除非你自己故意將其它Div設到1001層否則CalendarExtender 會在最頂層)&lt;br&gt;&lt;br&gt;如：&lt;/p&gt;&lt;br /&gt;&lt;p&gt;.cssCalendar .ajax__calendar_container&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; z-index:1000;&lt;br&gt;}&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-2594619284010349837?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/2594619284010349837/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/calendarextendergridview.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/2594619284010349837'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/2594619284010349837'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/calendarextendergridview.html' title='解決[Ajax]CalendarExtender彈出時被GridView或其它物件遮擋的問題'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_2sQfBxJU9mI/S8XWafRbHtI/AAAAAAAAMB4/dnB3U4cFIvM/s72-c/2010-04-14_223340_thumb%5B2%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-846811042122293874</id><published>2010-04-14T22:23:00.001+08:00</published><updated>2010-04-14T22:25:45.214+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>GridView實作資料筆數、頁數統計(使用SqlDataSource繫結方式)</title><content type='html'>&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S8XP9zaLaqI/AAAAAAAAMBs/GlDcP5WCKoU/s1600-h/2010-04-14_220709%5B4%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-04-14_220709" border="0" alt="2010-04-14_220709" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S8XP_H6TAyI/AAAAAAAAMBw/2v2dnury-gA/2010-04-14_220709_thumb%5B2%5D.jpg?imgmax=800" width="504" height="341"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;br&gt;在此要介紹的是使用GridView指定DataSourceID為SqlDataSource的資料繫結方式情況下，實現如上圖統計GridView的資料筆數與分頁數功能。&lt;br&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;計算GridView筆數：&lt;/font&gt;&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;'計算筆數&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; SqlDataSource_Selected(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; SqlDataSource.Selected&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    CountLots.Text = &lt;span style="color: #006080"&gt;"合計"&lt;/span&gt; + e.AffectedRows.ToString() + &lt;span style="color: #006080"&gt;"筆"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;font color="#808080"&gt;注意：利用 SqlDataSource取得資料受影響筆數必須要將DataSourceMode設為DataSet，否則取得的筆數皆為0。&lt;/font&gt;&lt;br&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;計算GridView頁數：&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;'計算頁數&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; GridView_DataBound(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; GridView.DataBound&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; CountPage &lt;span style="color: #0000ff"&gt;Is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; currentPage &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = GridView.PageIndex + 1&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        CountPage.Text = &lt;span style="color: #006080"&gt;" 共"&lt;/span&gt; &amp;amp; GridView.PageCount.ToString() &amp;amp; &lt;span style="color: #006080"&gt;"頁"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-846811042122293874?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/846811042122293874/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/gridviewsqldatasource.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/846811042122293874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/846811042122293874'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/gridviewsqldatasource.html' title='GridView實作資料筆數、頁數統計(使用SqlDataSource繫結方式)'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_2sQfBxJU9mI/S8XP_H6TAyI/AAAAAAAAMBw/2v2dnury-gA/s72-c/2010-04-14_220709_thumb%5B2%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-8565242160232138162</id><published>2010-04-14T21:53:00.001+08:00</published><updated>2010-04-14T21:53:27.530+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>Asp.net加密Web.config檔的資料庫&lt;connectionStrings&gt;連線資訊內容</title><content type='html'>&lt;p&gt;在&lt;strong&gt;Web.config&lt;/strong&gt;檔中的&lt;strong&gt;&amp;lt;connectionString&amp;gt;&lt;/strong&gt;區段儲存的是資料庫的連線資訊，包含主機IP、資料庫登入帳號、密碼等等重要機密資訊。因此在將網站正式上線以前必須作的其中一項重要事情，便是將&amp;lt;connectionString&amp;gt;區段中的重要資訊經過加密轉換，在此我們選擇使用&lt;a href="http://msdn.microsoft.com/zh-tw/library/system.configuration.rsaprotectedconfigurationprovider%28VS.80%29.aspx"&gt;RsaProtectedConfigurationProvider&lt;/a&gt;類別的加密解密方式來實現保護&amp;lt;connectionString&amp;gt;的功能。&lt;br&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;加密方法：&lt;/font&gt;&lt;br&gt;1、從開始→執行中輸入cmd指令來開啟DOS指令視窗&lt;br&gt;2、在DOS視窗中我們需要先切換至.NET Framework目錄下來執行：因此&amp;nbsp; 輸入&lt;strong&gt;cd \WINDOWS\Microsoft.Net\Framework\v2.0.*&lt;br&gt;&lt;/strong&gt;3、在此目錄下有支&lt;b&gt;aspnet_regiis&lt;/b&gt;.exe的程式，我們使用此支執行檔來實現加密的功能：輸入&lt;strong&gt;aspnet_regiis -pe "connectionStrings" -app "/網站名" -prov "RSAProtectedConfigurationProvider"&lt;br&gt;&lt;a href="http://lh5.ggpht.com/_2sQfBxJU9mI/S8XI0YyiSLI/AAAAAAAAMBk/zk10Qd_flEg/s1600-h/2010-04-14_215143%5B4%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-04-14_215143" border="0" alt="2010-04-14_215143" src="http://lh3.ggpht.com/_2sQfBxJU9mI/S8XI1pkLJgI/AAAAAAAAMBo/GyI_bVlTzEY/2010-04-14_215143_thumb%5B2%5D.jpg?imgmax=800" width="504" height="176"&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;&lt;/strong&gt;&lt;font color="#0000ff"&gt;解密方法：&lt;/font&gt;&lt;br&gt;1、同上先切換至.NET Framework目錄下來執行&lt;b&gt;aspnet_regiis&lt;/b&gt;.exe的程式&lt;br&gt;2、輸入&lt;strong&gt;aspnet_regiis -pd "connectionStrings" -app "/網站名" -prov "RSAProtectedConfigurationProvider"&lt;br&gt;&lt;br&gt;&lt;/strong&gt;&lt;font color="#ff80c0"&gt;參數說明：&lt;/font&gt;&lt;/p&gt; &lt;p&gt;-pe : 加密 &lt;p&gt;-pd : 解密 &lt;p&gt;-app : 欲加密的網站目錄名稱 &lt;p&gt;-prov : 加密方式&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-8565242160232138162?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/8565242160232138162/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/aspnetwebconfig.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8565242160232138162'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8565242160232138162'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/aspnetwebconfig.html' title='Asp.net加密Web.config檔的資料庫&amp;lt;connectionStrings&amp;gt;連線資訊內容'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_2sQfBxJU9mI/S8XI1pkLJgI/AAAAAAAAMBo/GyI_bVlTzEY/s72-c/2010-04-14_215143_thumb%5B2%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-175429521990619742</id><published>2010-04-14T21:03:00.001+08:00</published><updated>2010-04-14T21:03:21.874+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>剖析器錯誤訊息：無法從組件……載入型別……(解決方法)</title><content type='html'>&lt;p&gt;&lt;strong&gt;剖析器錯誤訊息: 無法從組件 &lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' &lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;載入型別 'System.Web.UI.Compatibility.CompareValidator'。&lt;/strong&gt;&lt;br&gt;&lt;br&gt;錯誤原因：&lt;br&gt;在Asp.Net網頁運行時出現此訊息，代表您運行的網站程式碼中使用了Ajax Control Toolkit For .NET3.5 SP1版本的控制項；而運行的Visual Studio 2008 環境未安裝SP1更新補丁。&lt;br&gt;&lt;br&gt;解決方法：&lt;br&gt;下載&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=27673C47-B3B5-4C67-BD99-84E525B5CE61&amp;amp;displaylang=en"&gt;Visual Studio 2008 Sp1&lt;/a&gt;(ISO檔)後安裝更新檔即可。&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-175429521990619742?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/175429521990619742/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/blog-post.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/175429521990619742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/175429521990619742'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/blog-post.html' title='剖析器錯誤訊息：無法從組件……載入型別……(解決方法)'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-2677783701141349398</id><published>2010-04-06T19:57:00.001+08:00</published><updated>2010-04-06T19:57:51.408+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>Asp.Net -Cookie讀取中文變亂碼的解決方法</title><content type='html'>&lt;p&gt;有時我的可能因為特別需求，必須使用Cookie來存放簡短的中文字。但中文字的編碼與Cookie預設的編碼方式不同，因此必須先行在URL傳輸過程中經過一道編碼、解碼的程序，才不會發生中文字在Cookie中讀取出來為亂碼的情況。&lt;br&gt;&lt;br&gt;一般建立Cookie的寫法為：&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; cookie &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; HttpCookie(&lt;span style="color: #006080"&gt;"UserInfo"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;cookie.Values.Add(&lt;span style="color: #006080"&gt;"Login"&lt;/span&gt;, &lt;span style="color: #006080"&gt;"OK"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;cookie.Values.Add(&lt;span style="color: #006080"&gt;"No"&lt;/span&gt;, dr(&lt;span style="color: #006080"&gt;"員工編號"&lt;/span&gt;))&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;cookie.Values.Add(&lt;span style="color: #006080"&gt;"Name"&lt;/span&gt;, (dr(&lt;span style="color: #006080"&gt;"員工姓名"&lt;/span&gt;))&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;Response.Cookies.Add(cookie)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br&gt;由於其中"Name"的Cookie內容存放的是中文字員工姓名，讀取時使用Request.Cookies("UserInfo")("Name")後，會發現讀到的中文已經變為亂碼。&lt;br&gt;&lt;br&gt;我們將原本的寫法加入&lt;strong&gt;&lt;a href="http://msdn.microsoft.com/zh-tw/library/4fkewx0t%28VS.80%29.aspx" target="_blank"&gt;HttpUtility.UrlEncode&lt;/a&gt;&lt;/strong&gt;(編碼)與&lt;a href="http://msdn.microsoft.com/zh-tw/library/system.web.httputility.urldecode%28VS.80%29.aspx" target="_blank"&gt;HttpUtility.UrlDecode&lt;/a&gt;&lt;strong&gt;&lt;/strong&gt;(解碼)，在URL中傳輸而進行編碼的字串轉換來解決亂碼的問題。修改後程式碼如下：&lt;br&gt;&lt;br&gt;建立Cookie時編碼：&lt;/p&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; cookie &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; HttpCookie(&lt;span style="color: #006080"&gt;"UserInfo"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;cookie.Values.Add(&lt;span style="color: #006080"&gt;"Login"&lt;/span&gt;, &lt;span style="color: #006080"&gt;"OK"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;cookie.Values.Add(&lt;span style="color: #006080"&gt;"No"&lt;/span&gt;, dr(&lt;span style="color: #006080"&gt;"員工編號"&lt;/span&gt;))&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;cookie.Values.Add(&lt;span style="color: #006080"&gt;"Name"&lt;/span&gt;, HttpUtility.UrlEncode(dr(&lt;span style="color: #006080"&gt;"員工姓名"&lt;/span&gt;)))&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;Response.Cookies.Add(cookie)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br&gt;讀取時解碼：&lt;br&gt;HttpUtility.UrlDecode(Request.Cookies("UserInfo")("Name"))&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-2677783701141349398?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/2677783701141349398/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/aspnet-cookie.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/2677783701141349398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/2677783701141349398'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/aspnet-cookie.html' title='Asp.Net -Cookie讀取中文變亂碼的解決方法'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-7930205537267512364</id><published>2010-04-03T15:34:00.001+08:00</published><updated>2010-04-03T15:48:10.564+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>伺服器 'Localhost\SQLEXPRESS' 上的 MSDTC 無法使用。</title><content type='html'>&lt;p&gt;&lt;font color="#000000"&gt;若在操作Asp.Net網站時發生『&lt;/font&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;伺服器 'Localhost\SQLEXPRESS' 上的 MSDTC 無法使用。&lt;/strong&gt;&lt;/font&gt;&lt;font color="#000000"&gt;』的錯誤訊息，那麼一定是在進行資料庫存取時使用了&lt;/font&gt;&lt;a href="http://msdn.microsoft.com/zh-tw/library/system.transactions.transactionscope%28VS.80%29.aspx" target="_blank"&gt;&lt;font color="#535353"&gt;&lt;font color="#ff0000"&gt;TransactionScope&lt;/a&gt;&lt;font color="#000000"&gt;的交易機制來確保交易的完整性。&lt;/font&gt;&lt;br&gt;&lt;br&gt;&lt;font color="#000000"&gt;在程式碼中加入TransactionScope交易機制的同時，也需要在網站Server上開啟&lt;/font&gt;&lt;a href="http://en.wikipedia.org/wiki/Distributed_Transaction_Coordinator" target="_blank"&gt;MSDTC&lt;/a&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt;(Microsoft Distributed Transaction Coordination)分散式異動交易的系統服務，否則就會看到『伺服器 'Localhost\SQLEXPRESS' 上的 MSDTC 無法使用。』的錯誤訊息。由於MSDTC在XP系統中預設是不開啟，因此我們需要將其開啟並設為自動開啟。&lt;br&gt;&lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font color="#000000"&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;&lt;strong&gt;開啟MSDTC方法&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt;：(以XP為例)&lt;br&gt;[控制台]→[系統管理工具]→[服務]&lt;br&gt;找到『&lt;strong&gt;Distributed Transaction Coordinator&lt;/strong&gt;』的服務名稱&lt;br&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S7bviULrG-I/AAAAAAAAMBI/FpGUJ8Vr9Yg/s1600-h/2010-04-03_152712%5B4%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-04-03_152712" border="0" alt="2010-04-03_152712" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S7bvjzuDpvI/AAAAAAAAMBM/ZSY9X3E-OK8/2010-04-03_152712_thumb%5B2%5D.jpg?imgmax=800" width="504" height="192"&gt;&lt;/a&gt; &lt;br&gt;在其名稱上按[右鍵]→[內容]&lt;br&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S7bvk8o-M4I/AAAAAAAAMBQ/YNnlyOj4ANw/s1600-h/2010-04-03_152846%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-04-03_152846" border="0" alt="2010-04-03_152846" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S7bvl69c0_I/AAAAAAAAMBU/Z-9vajdRXys/2010-04-03_152846_thumb%5B1%5D.jpg?imgmax=800" width="487" height="243"&gt;&lt;/a&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;br&gt;進入內容後如下圖將&lt;strong&gt;啟動類型&lt;/strong&gt;改為&lt;font color="#ff0000"&gt;自動&lt;/font&gt;、&lt;strong&gt;服務狀態&lt;/strong&gt;將其&lt;font color="#ff0000"&gt;啟動&lt;/font&gt;。&lt;br&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S7bvmyANaQI/AAAAAAAAMBY/qA5RoLmqrDw/s1600-h/2010-04-03_152945%5B5%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-04-03_152945" border="0" alt="2010-04-03_152945" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S7bvofsYnZI/AAAAAAAAMBc/dJB31IdTgrw/2010-04-03_152945_thumb%5B3%5D.jpg?imgmax=800" width="404" height="450"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;br&gt;完成設定後，Asp.Net網站即可正確的執行TransactionScope交易機制。&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-7930205537267512364?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/7930205537267512364/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/msdtc.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/7930205537267512364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/7930205537267512364'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/msdtc.html' title='伺服器 &amp;#39;Localhost\SQLEXPRESS&amp;#39; 上的 MSDTC 無法使用。'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_2sQfBxJU9mI/S7bvjzuDpvI/AAAAAAAAMBM/ZSY9X3E-OK8/s72-c/2010-04-03_152712_thumb%5B2%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-998715372834538636</id><published>2010-04-03T14:55:00.001+08:00</published><updated>2010-04-03T14:56:40.127+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>GridView隱藏欄位(Visible="Flase")後取不到值的替代方法</title><content type='html'>&lt;p&gt;有時我們需要在GridView中設置欄位來取值，以作為後續動作的資料來源判斷依據，但又不想在使用者瀏覽時顯示此欄位。例：GridView中使用BoundField 來取得存檔日期的值同時將其欄位設為不顯示&lt;em&gt;，&amp;lt;asp:BoundField DataField="存檔日期" Visible="false" /&amp;gt;&lt;/em&gt;。這時在GridView的RowDataBound事件中使用e.Row.Cells(0).Text的方式取值會發現無法順利取到值。 &lt;br&gt;&lt;br&gt;因此需要使用另一種替代方式來達到此目的的實現，在Asp.Net中有個專為隱藏數值設計的控制項&lt;strong&gt;HiddenField&lt;/strong&gt;，我們要作的就是將原本&lt;em&gt;&amp;lt;asp:BoundField DataField="存檔日期" Visible="false" /&amp;gt;&lt;/em&gt;的資料繫結方式改為使用HiddenField的Value值與存檔日期繫結，並將此HiddenField控制項置於GridView的&lt;strong&gt;TemplateField&lt;/strong&gt;中。&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;asp:TemplateField&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;ItemTemplate&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &amp;lt;asp:HiddenField ID=&lt;span style="color: #006080"&gt;"SaveTime"&lt;/span&gt; runat=&lt;span style="color: #006080"&gt;"server"&lt;/span&gt; Value=&lt;span style="color: #008000"&gt;'&amp;lt;%# Eval("存檔日期") %&amp;gt;' /&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;/ItemTemplate&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;/asp:TemplateField&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br&gt;如此便可在GridView的RowDataBound事件中使用&lt;strong&gt;FindControl&lt;/strong&gt;的方式來取得GridView各個欄位中的存檔日期值。&lt;/p&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; GridView_RowDataBound(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.Web.UI.WebControls.GridViewRowEventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; GridView.RowDataBound&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; e.Row.RowType = DataControlRowType.DataRow &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        Response.Write(&lt;span style="color: #0000ff"&gt;CType&lt;/span&gt;(e.Row.FindControl(&lt;span style="color: #006080"&gt;"SaveTime"&lt;/span&gt;), HiddenField).Value)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-998715372834538636?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/998715372834538636/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/gridviewvisible.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/998715372834538636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/998715372834538636'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/gridviewvisible.html' title='GridView隱藏欄位(Visible=&amp;quot;Flase&amp;quot;)後取不到值的替代方法'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-197170887349428474</id><published>2010-04-03T11:17:00.002+08:00</published><updated>2010-04-27T11:58:11.264+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>DataList包DataList中建立子DataList的ItemCommand事件</title><content type='html'>DataList包DataList此種用法最常見的如部落格文章的回應功能。頁面中使用DataList來Show出多筆文章，文章的DataList中再套入Datalist來顯示多筆回應內容。如此形成兩層DataList的情況後，我們在實作時首先會發現在Vistual Studio中找不到子DataList的事件選項供自己選擇。&lt;br /&gt;&lt;br /&gt;遇到此種情況便需要我們自己來手動建立子DataList事件了。在網路上你可以找到不只一種建立子DataList的方法，在此我將個人認為最簡單的建立事件方法記錄如下。&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: blue;"&gt;方法：&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;手動建立&lt;b&gt;Public Sub&lt;/b&gt;後，在子DataList中指定&lt;b&gt;OnItemCommand&lt;/b&gt;事件並觸發Public Sub。我們需要作的事是在DataList2中手動輸入&lt;b&gt;OnItemCommand=" Plublic Sub事件名稱 "&lt;/b&gt; (如程式第10行)。&lt;br /&gt;&lt;br /&gt;Test.aspx&lt;br /&gt;&lt;div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;"&gt;&lt;div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt;   1:&lt;/span&gt; &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:DataList&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="DataList1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: red;"&gt;DataKeyField&lt;/span&gt;&lt;span style="color: blue;"&gt;="拜訪編號"&lt;/span&gt; &lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt;   2:&lt;/span&gt;     &lt;span style="color: red;"&gt;DataSourceID&lt;/span&gt;&lt;span style="color: blue;"&gt;="SqlDataSource1"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt;   3:&lt;/span&gt;     &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum4" style="color: #606060;"&gt;   4:&lt;/span&gt;         &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;font&lt;/span&gt; &lt;span style="color: red;"&gt;color&lt;/span&gt;&lt;span style="color: blue;"&gt;="red"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum5" style="color: #606060;"&gt;   5:&lt;/span&gt;             拜訪編號:&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum6" style="color: #606060;"&gt;   6:&lt;/span&gt;             &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:Label&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="拜訪編號Label"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: red;"&gt;Text&lt;/span&gt;&lt;span style="color: blue;"&gt;='&amp;lt;%# Eval("拜訪編號") %&amp;gt;'&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum7" style="color: #606060;"&gt;   7:&lt;/span&gt;             &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:Button&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="Button1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: red;"&gt;Text&lt;/span&gt;&lt;span style="color: blue;"&gt;="按鈕1"&lt;/span&gt; &lt;span style="color: red;"&gt;CommandName&lt;/span&gt;&lt;span style="color: blue;"&gt;="TestButton"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum8" style="color: #606060;"&gt;   8:&lt;/span&gt;         &lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;font&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum9" style="color: #606060;"&gt;   9:&lt;/span&gt;         &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:DataList&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="DataList2"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum10" style="color: #606060;"&gt;  10:&lt;/span&gt;         &lt;span style="color: red;"&gt;DataSourceID&lt;/span&gt;&lt;span style="color: blue;"&gt;="SqlDataSource2"&lt;/span&gt; &lt;span style="color: red;"&gt;OnItemCommand&lt;/span&gt;&lt;span style="color: blue;"&gt;="DataList2_ItemCommand"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum11" style="color: #606060;"&gt;  11:&lt;/span&gt;         &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum12" style="color: #606060;"&gt;  12:&lt;/span&gt;             拜訪目的:&lt;/pre&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum13" style="color: #606060;"&gt;  13:&lt;/span&gt;             &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:Label&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="拜訪目的Label"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: red;"&gt;Text&lt;/span&gt;&lt;span style="color: blue;"&gt;='&amp;lt;%# Eval("拜訪目的") %&amp;gt;'&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum14" style="color: #606060;"&gt;  14:&lt;/span&gt;             &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:Button&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="Button1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: red;"&gt;Text&lt;/span&gt;&lt;span style="color: blue;"&gt;="按鈕2"&lt;/span&gt; &lt;span style="color: red;"&gt;CommandName&lt;/span&gt;&lt;span style="color: blue;"&gt;="TestButton2"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum15" style="color: #606060;"&gt;  15:&lt;/span&gt;         &lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum16" style="color: #606060;"&gt;  16:&lt;/span&gt;         &lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:DataList&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum17" style="color: #606060;"&gt;  17:&lt;/span&gt;         &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;br&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum18" style="color: #606060;"&gt;  18:&lt;/span&gt;     &lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum19" style="color: #606060;"&gt;  19:&lt;/span&gt; &lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;asp:DataList&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;在Test.aspx.vb中建立Public Sub，其名稱為&lt;b&gt;OnItemCommand&lt;/b&gt;事件指定呼叫的名稱。&lt;br /&gt;&lt;br /&gt;Test.aspx.vb&lt;br /&gt;&lt;br /&gt;&lt;div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;"&gt;&lt;br /&gt;&lt;div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt;   1:&lt;/span&gt; &lt;span style="color: blue;"&gt;Public&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; DataList2_ItemCommand(&lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; source &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Object&lt;/span&gt;, &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.Web.UI.WebControls.DataListCommandEventArgs)&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt;   2:&lt;/span&gt;     &lt;span style="color: blue;"&gt;If&lt;/span&gt; e.CommandName = &lt;span style="color: #006080;"&gt;"TestButton2"&lt;/span&gt; &lt;span style="color: blue;"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt;   3:&lt;/span&gt;         Response.Write(&lt;span style="color: #006080;"&gt;"This is DataList2"&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum4" style="color: #606060;"&gt;   4:&lt;/span&gt;     &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum5" style="color: #606060;"&gt;   5:&lt;/span&gt; &lt;span style="color: blue;"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;在我們按下&lt;b&gt;按鈕2&lt;/b&gt;後便可以正確觸發子DataList的I&lt;b&gt;temCommand&lt;/b&gt;事件&lt;b&gt;：&lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S7azRTYLgZI/AAAAAAAAMBA/bFYB64f-emw/s1600-h/2010-04-03_105109%5B6%5D.jpg"&gt;&lt;img alt="2010-04-03_105109" border="0" height="231" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S7azSFTD_XI/AAAAAAAAMBE/RQ_v5DP5wAw/2010-04-03_105109_thumb%5B2%5D.jpg?imgmax=800" style="border: 0px none; display: inline;" title="2010-04-03_105109" width="241" /&gt;&lt;/a&gt;&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-197170887349428474?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/197170887349428474/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/04/datalistdatalistdatalistitemcommand.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/197170887349428474'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/197170887349428474'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/04/datalistdatalistdatalistitemcommand.html' title='DataList包DataList中建立子DataList的ItemCommand事件'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_2sQfBxJU9mI/S7azSFTD_XI/AAAAAAAAMBE/RQ_v5DP5wAw/s72-c/2010-04-03_105109_thumb%5B2%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-6452893686142039906</id><published>2010-03-20T15:16:00.001+08:00</published><updated>2010-03-20T15:18:10.273+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>Asp.Net的錨點(#連結)功能，支援FireFox</title><content type='html'>&lt;p&gt;所謂錨點(#連結)的作法為超連結網址後方加上#參數。最常見的應用為指定回應內容網址的功能，讓使用者點擊回應連結後可直接將瀏覽器畫面定位在頁面下方的回應內容位置。&lt;br&gt;&lt;br&gt;錨點#的用法如下：&lt;br&gt;Ex：&lt;a href="http://localhost/Test/Test.aspx#Link"&gt;http://localhost/Test/Test.aspx#Link&lt;/a&gt;&lt;br&gt;如此我們就可以在被連結頁面中指定其連結位置&lt;br&gt;Ex：&lt;font color="#ff0000"&gt;&lt;strong&gt;&amp;lt;a id="Link"&amp;gt;&amp;lt;/a&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/strong&gt;&lt;font color="#000000"&gt;上面這種寫法支持xhtml網頁標準，與傳統的錨點寫法&amp;lt;a name="#Link"&amp;gt;&amp;lt;/a&amp;gt;不同的是不使用name來指定錨點改用id指定且去掉了加上#字號。使用name一來會多了無意義的&amp;lt;a&amp;gt;連結，且未指定href也不符合xhtml標準，而使用id指定錨點不侷限於&amp;lt;a&amp;gt;標籤，可用於其它如&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;h1&amp;gt;&amp;lt;li&amp;gt;等標籤中。&lt;strong&gt;最重要的是使用id指定錨點才能讓Firefox、Opera、Chorm等瀏覽器作用！不再是IE Only的功能了。&lt;br&gt;&lt;/strong&gt;&lt;/font&gt;&lt;br&gt;&lt;/font&gt;&lt;font color="#000000"&gt;下面用個簡單的連結範例來實作錨點功能：&lt;br&gt;在Test.aspx頁面建立HyperLink控制項，並指定其超連結網址為Test2.aspx，同時加上錨點參數#Link&lt;/font&gt;&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Test" %&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;!&lt;/span&gt;&lt;span style="color: #800000"&gt;DOCTYPE&lt;/span&gt; &lt;span style="color: #ff0000"&gt;html&lt;/span&gt; &lt;span style="color: #ff0000"&gt;PUBLIC&lt;/span&gt; &lt;span style="color: #0000ff"&gt;"-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;html&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="http://www.w3.org/1999/xhtml"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;head&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;title&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;title&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;head&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="form1"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:HyperLink&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="HyperLink1"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;NavigateUrl&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Test2.aspx#Link"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        錨點連結至Test2.aspx&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:HyperLink&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;html&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br&gt;並在Test2.aspx中建立1～15數字來區別位置，我們將錨點#Link建立在數字11上&lt;/p&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test2.aspx.vb" Inherits="Test2" %&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;!&lt;/span&gt;&lt;span style="color: #800000"&gt;DOCTYPE&lt;/span&gt; &lt;span style="color: #ff0000"&gt;html&lt;/span&gt; &lt;span style="color: #ff0000"&gt;PUBLIC&lt;/span&gt; &lt;span style="color: #0000ff"&gt;"-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;html&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="http://www.w3.org/1999/xhtml"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;head&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;title&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;title&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;head&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="form1"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    第一行&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    1&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    2&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    3&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    4&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    5&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    6&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    7&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    8&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    9&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    10&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;a&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Link"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;a&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    錨點連結點11&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    12&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    13&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    14&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    15&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;html&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br&gt;好了，現在我們輸入未指定錨點#連結的網址看看Test2.aspx中數字11的位置&lt;br&gt;&lt;a href="http://localhost/Test/Test2.aspx"&gt;http://localhost/Test/Test2.aspx&lt;/a&gt;，會發現數字11的位置在瀏覽器最下方。&lt;br&gt;&lt;a href="http://lh6.ggpht.com/_2sQfBxJU9mI/S6R2I-zqBDI/AAAAAAAAMAY/KDftGc9a3UM/s1600-h/2010-03-20_145109%5B3%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2010-03-20_145109" border="0" alt="2010-03-20_145109" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S6R2KBWV29I/AAAAAAAAMAc/ZxKbDBhErPY/2010-03-20_145109_thumb%5B1%5D.jpg?imgmax=800" width="259" height="743"&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;現在再透過剛建立的Test.aspx上的HyperLink連結至Test2.aspx看看有何不同。HyperLink的超連結網址為&lt;a href="http://localhost/Test/Test2.aspx#Link"&gt;http://localhost/Test/Test2.aspx#Link&lt;/a&gt;，數字11的位置可以完整看見了，這就是錨點的用途很簡易實現。&lt;br&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S6R2LSmlQbI/AAAAAAAAMAg/-6E0fB4b3Tg/s1600-h/2010-03-20_144849%5B3%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2010-03-20_144849" border="0" alt="2010-03-20_144849" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S6R2MSck-oI/AAAAAAAAMAk/KMVhZCLahQo/2010-03-20_144849_thumb%5B1%5D.jpg?imgmax=800" width="217" height="744"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-6452893686142039906?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/6452893686142039906/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/03/aspnetfirefox.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6452893686142039906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6452893686142039906'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/03/aspnetfirefox.html' title='Asp.Net的錨點(#連結)功能，支援FireFox'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_2sQfBxJU9mI/S6R2KBWV29I/AAAAAAAAMAc/ZxKbDBhErPY/s72-c/2010-03-20_145109_thumb%5B1%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-2973298738987533691</id><published>2010-03-16T21:13:00.001+08:00</published><updated>2010-03-16T21:13:37.680+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>DropDownList資料繫結後加入"請選擇"靜態項目</title><content type='html'>&lt;p&gt;在Asp.Net的DropDownList控制項中，除了可以使用資料繫結(DataBind)的方式，也可使用靜態方式建立選項項目，亦可兩者同時建立。我們不用CodeBehind的寫法直接使用滑鼠完成DropDownList同時建立動態與靜態項目，一個很基礎又很實用的技巧記錄如下。&lt;br&gt;&lt;br&gt;首先必須將DropListBox中的&lt;strong&gt;&lt;font color="#ff0000"&gt;AppendDataBoundItems&lt;/font&gt;&lt;/strong&gt;屬性設定為&lt;strong&gt;True&lt;/strong&gt;，其功用如下方說明所示：&lt;em&gt;&lt;u&gt;將資料繫結項目附加至靜態宣告的清單項目&lt;/u&gt;&lt;/em&gt;。原來Vistual Studio都幫我們預先做好了，只要設定為Ture就可以。&lt;br&gt;&lt;a href="http://lh6.ggpht.com/_2sQfBxJU9mI/S5-D1Y4NtQI/AAAAAAAAL_8/63ye0RfjcHg/s1600-h/2010-03-16_210002%5B2%5D.jpg"&gt;&lt;strong&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-03-16_210002" border="0" alt="2010-03-16_210002" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S5-D3Ugks-I/AAAAAAAAMAA/qRp2a4o-Ezg/2010-03-16_210002_thumb.jpg?imgmax=800" width="239" height="234"&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&lt;/strong&gt;接著將靜態項目加入DropDownList中，方法如下圖：&lt;br&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S5-D4CTjbFI/AAAAAAAAMAE/wfAJytQwqTs/s1600-h/2010-03-16_210128%5B2%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-03-16_210128" border="0" alt="2010-03-16_210128" src="http://lh3.ggpht.com/_2sQfBxJU9mI/S5-D5BQ34eI/AAAAAAAAMAI/wD6UJ5VWjus/2010-03-16_210128_thumb.jpg?imgmax=800" width="244" height="127"&gt;&lt;/a&gt; &lt;br&gt;&lt;a href="http://lh6.ggpht.com/_2sQfBxJU9mI/S5-D6QcFRdI/AAAAAAAAMAM/AlAnZ45CM-o/s1600-h/2010-03-16_210303%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-03-16_210303" border="0" alt="2010-03-16_210303" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S5-D7TPMQ-I/AAAAAAAAMAQ/8SuIB7mZSa0/2010-03-16_210303_thumb%5B1%5D.jpg?imgmax=800" width="503" height="339"&gt;&lt;/a&gt; &lt;br&gt;完成後的程式碼如下：&lt;br&gt;&amp;lt;asp:DropDownList ID="DropDownList" runat="server"&amp;nbsp; DataSourceID="SqlDataSource" DataTextField="Test1" DataValueField="Test2"&amp;nbsp; &lt;strong&gt;&lt;font color="#ff0000"&gt;AppendDataBoundItems="True"&lt;/font&gt;&lt;/strong&gt; &amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;&lt;font color="#ff0000"&gt;&amp;lt;asp:ListItem Value="0"&amp;gt;請選擇&amp;lt;/asp:ListItem&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/strong&gt;&amp;lt;/asp:DropDownList&amp;gt;&lt;br&gt;&lt;/p&gt; &lt;p&gt;&amp;lt;asp:SqlDataSource ID="SqlDataSource" runat="server"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConnectionString="&amp;lt;%$ ConnectionStrings:TestConnectionString %&amp;gt;" &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SelectCommand="Select * From Test"&amp;gt;&lt;br&gt;&amp;lt;/asp:SqlDataSource&amp;gt;&amp;nbsp;   &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-2973298738987533691?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/2973298738987533691/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/03/dropdownlist.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/2973298738987533691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/2973298738987533691'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/03/dropdownlist.html' title='DropDownList資料繫結後加入&amp;quot;請選擇&amp;quot;靜態項目'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_2sQfBxJU9mI/S5-D3Ugks-I/AAAAAAAAMAA/qRp2a4o-Ezg/s72-c/2010-03-16_210002_thumb.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-4664219889253941541</id><published>2010-03-16T20:38:00.001+08:00</published><updated>2010-03-16T20:40:22.580+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>Class類別中的Response、Server、Request未宣告解決方法(使用HttpContext.Current屬性)</title><content type='html'>&lt;p&gt;對於需要重複使用的程式碼，我們通常可以寫在Asp.Net的Public Class類別中，再到WebForm中呼叫。例如在Test.aspx.vb的Page Load中使用此段程式碼來判斷使用者是否已登入。&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; Page_Load(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Load&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; Server.HtmlEncode(Request.Cookies(&lt;span style="color: #006080"&gt;"UserInfo"&lt;/span&gt;)(&lt;span style="color: #006080"&gt;"Login"&lt;/span&gt;)) = &lt;span style="color: #0000ff"&gt;True&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        Response.Redirect(&lt;span style="color: #006080"&gt;"Default.aspx"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        Response.Redirect(&lt;span style="color: #006080"&gt;"Login.aspx"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br&gt;我們需要在每一個頁面都先進行使用者是否登入的判斷，因此將此區段程式碼取出寫在Public Class類別中提供給每個頁面呼叫。&lt;br&gt;&lt;br&gt;在Asp.Net中建立一個名為Class1.vb的類別，接著把上面的程式碼貼入Public Sub中會發現如下圖畫面中的錯誤：&lt;br&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S5972GQLe0I/AAAAAAAAL_0/gLtm1Iv2idE/s1600-h/2010-03-16_201928%5B4%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2010-03-16_201928" border="0" alt="2010-03-16_201928" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S5973PP1fcI/AAAAAAAAL_4/4Bh8d151vTE/2010-03-16_201928_thumb%5B2%5D.jpg?imgmax=800" width="504" height="142"&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;在Class1.vb中出現&lt;strong&gt;Server、Request、Response&lt;/strong&gt;皆&lt;strong&gt;&lt;font color="#ff0000"&gt;未宣告&lt;/font&gt;&lt;/strong&gt;的錯誤訊息。&lt;br&gt;&lt;br&gt;因為&lt;strong&gt;Server、Request、Response&lt;/strong&gt;的預設值是Page，即Page.Server&lt;strong&gt;、&lt;/strong&gt;Page.Request、Page.Response。也就是說Page.Response的返回值是當前頁面的值，而在Class1.vb類別中無法得知當前頁面的值為何。&lt;br&gt;&lt;br&gt;因此需要透過Http從來源頁面中傳遞告知當前頁面為何，我們在每個錯誤訊息前面加上&lt;strong&gt;&lt;a href="http://msdn.microsoft.com/zh-tw/library/system.web.httpcontext.current.aspx" target="_blank"&gt;HttpContext.Current&lt;/a&gt;&lt;/strong&gt;屬性：&lt;/p&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Imports&lt;/span&gt; Microsoft.VisualBasic&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Class&lt;/span&gt; Class1&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; Get_Cookie()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; HttpContext.Current.Server.HtmlEncode _&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        (HttpContext.Current.Request.Cookies(&lt;span style="color: #006080"&gt;"UserInfo"&lt;/span&gt;)(&lt;span style="color: #006080"&gt;"Login"&lt;/span&gt;)) = &lt;span style="color: #0000ff"&gt;True&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            HttpContext.Current.Response.Redirect(&lt;span style="color: #006080"&gt;"Default.aspx"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            HttpContext.Current.Response.Redirect(&lt;span style="color: #006080"&gt;"Login.aspx"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Class&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br&gt;最後，將Test.aspx.vb的Page_Load改為Call呼叫的方式來使用Class1.vb類別&lt;/p&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; Page_Load(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Load&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; Class1 &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; Class1&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Call&lt;/span&gt; Class1.Get_Cookie()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-4664219889253941541?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/4664219889253941541/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/03/classresponseserverrequesthttpcontextcu.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/4664219889253941541'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/4664219889253941541'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/03/classresponseserverrequesthttpcontextcu.html' title='Class類別中的Response、Server、Request未宣告解決方法(使用HttpContext.Current屬性)'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_2sQfBxJU9mI/S5973PP1fcI/AAAAAAAAL_4/4Bh8d151vTE/s72-c/2010-03-16_201928_thumb%5B2%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-5689876207218789168</id><published>2010-03-10T21:00:00.002+08:00</published><updated>2010-03-20T15:19:16.842+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>Alert視窗確認後Response.Redirect轉跳頁面的替代方法(含ScriptManager Ajax頁面轉跳方法)</title><content type='html'>&lt;a href="http://lh6.ggpht.com/_2sQfBxJU9mI/S5eX31M7q1I/AAAAAAAAL_c/3G9rDkJhyC8/s1600-h/2010-03-10_194728%5B6%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-03-10_194728" border="0" alt="2010-03-10_194728" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S5eX46QNtTI/AAAAAAAAL_g/aU6kZpHawOE/2010-03-10_194728_thumb%5B4%5D.jpg?imgmax=800" width="359" height="115"&gt;&lt;/a&gt; &lt;br&gt;在Asp.net中，需要在操作例如送出動作時，先&lt;b&gt;&lt;i&gt;彈出確認視窗之後轉跳到指定頁面&lt;/i&gt;&lt;/b&gt;的功能其實是非常常見的。此功能的實作算是非常基礎的，很多剛開始嘗試寫Asp.Net的人直覺寫法是一段JavaScript語法加上Response.Redirect來實現：&lt;br&gt;&lt;b&gt;&lt;span style="color: black"&gt;Response.Write&amp;nbsp;&amp;nbsp; "&amp;lt;script &amp;gt;alert('更新成功！');&amp;lt;/script&amp;gt;"&lt;br&gt;Response.Redirect("Default.aspx")&lt;br&gt;&lt;br&gt;&lt;/span&gt;&lt;/b&gt;此種直覺的寫法在實際執行時會發現，Alert的警告視窗不出現就直接轉跳頁面到Default.aspx去了。我也寫過這種無法正確執行的程式碼，因而誤以為自己語法寫錯了。Alert視窗呢？回頭仔細檢查語法發現並沒有寫錯，為何不顯示Alert呢？&lt;br&gt;&lt;br&gt;這是因為Response.Redirect是在未送出HttpHead前便執行了，而JavaScript又是需要在Client端才能Run，也就是說用了Response.Redirect在返回Client端以前頁面就已經被轉向至Default.aspx，那麼原本頁面的Alert便無法執行了。&lt;br&gt;&lt;br&gt;瞭解原因後，就可以使用其它方法來替代Response.Redirect來實現轉跳的功能。在JavaScript語法中本身已有頁面轉跳的功能語法，因此我們將上面原本無法正確執行的兩行程式碼合併為一行：&lt;br&gt;&lt;b&gt;&lt;span style="color: black"&gt;Response.Write("&amp;lt;script&amp;gt;alert('修改成功!'); &lt;span style="color: red"&gt;location.href='Default.aspx';&lt;/span&gt; &amp;lt;/script&amp;gt;")&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;/b&gt;直接在Alert後使用location.href=』轉跳網址...』，如此便可避免因頁面已轉跳無法將JavaScript返回Client端執行的問題。&lt;br&gt;&lt;br&gt;另外一種情況為在頁面中使用了&lt;b&gt;ScriptManager&lt;/b&gt;來實現Ajax的頁面。含有Ajax功能的頁面若使用上述方法來轉跳頁面，會發現Alert視窗也無法正確顯示出來，需改為下列的程式碼：&lt;br&gt;&lt;b&gt;ScriptManager.RegisterStartupScript(Me, Me.GetType(), "alert", "alert('修改成功!'); location.href='Default.aspx';", True)&lt;br&gt;&lt;br&gt;&lt;/b&gt;RegisterStartupScript類似Response.Write功能相仿，多了的Type與Key的參數。實際在顯示畫面的差別為，使用Response.Write時彈出的Alert視窗後面的頁面是空白的看不到任何頁面內容：&lt;br&gt;&amp;nbsp;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S5eX5xgtY2I/AAAAAAAAL_k/ok4lrhP_pdQ/s1600-h/2010-03-10_203629%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-03-10_203629" border="0" alt="2010-03-10_203629" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S5eX7PAKn_I/AAAAAAAAL_o/cIQIBKMY34g/2010-03-10_203629_thumb%5B1%5D.jpg?imgmax=800" width="455" height="204"&gt;&lt;/a&gt;&amp;nbsp; &lt;br&gt;&lt;br&gt;使用RegisterStartupScript時彈出的Alert視窗後面的頁面內容是可見的：&lt;br&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S5eX8nDepvI/AAAAAAAAL_s/urA09QDQ8WI/s1600-h/2010-03-10_203556%5B10%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-03-10_203556" border="0" alt="2010-03-10_203556" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S5eX9o8a_uI/AAAAAAAAL_w/1yWrgAjSb0Y/2010-03-10_203556_thumb%5B6%5D.jpg?imgmax=800" width="484" height="153"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;span style="color: blue"&gt;補充：&lt;/span&gt;&lt;/b&gt;&lt;br&gt;不含ScriptManager Ajax功能頁面的RegisterStartupScript寫法：&lt;br&gt;&lt;b&gt;Page.ClientScript.RegisterStartupScript(Me.GetType(), "Test", "&amp;lt;script&amp;gt;alert('修改成功!');location.href='Default.aspx';&amp;lt;/script&amp;gt;")&lt;/b&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-5689876207218789168?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/5689876207218789168/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/03/alertresponseredirectscriptmanager-ajax.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/5689876207218789168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/5689876207218789168'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/03/alertresponseredirectscriptmanager-ajax.html' title='Alert視窗確認後Response.Redirect轉跳頁面的替代方法(含ScriptManager Ajax頁面轉跳方法)'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_2sQfBxJU9mI/S5eX46QNtTI/AAAAAAAAL_g/aU6kZpHawOE/s72-c/2010-03-10_194728_thumb%5B4%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-8152659577683248370</id><published>2010-03-09T21:50:00.001+08:00</published><updated>2010-03-09T21:53:53.130+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>HyperLink使用Eval繫結資料庫傳遞QueryString值</title><content type='html'>&lt;p&gt;要實作的功能為網站首頁最新公告欄位，我們想要透過點擊公告主題來進入詳情頁面(PostDetail.aspx)，如下圖：&lt;br&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S5ZSFcfTgHI/AAAAAAAAL_U/VYLsibvqMek/s1600-h/2010-03-09_213050%5B5%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-03-09_213050" border="0" alt="2010-03-09_213050" src="http://lh3.ggpht.com/_2sQfBxJU9mI/S5ZSGUCLgVI/AAAAAAAAL_Y/Ywukcgg4tNs/2010-03-09_213050_thumb%5B3%5D.jpg?imgmax=800" width="504" height="77"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;br&gt;紅框處使用&lt;strong&gt;HyperLink&lt;/strong&gt;來繫結公告主題，而&lt;strong&gt;HyperLink&lt;/strong&gt;的NavigateUrl屬性我們要連結至詳情頁面(PostDetail.aspx)並使用QueryString傳值的方式來傳遞公告編號至詳情頁面。&lt;br&gt;&lt;br&gt;若是屬於GridView中的&lt;strong&gt;HyperLink&lt;/strong&gt;其傳遞QueryString的寫法是：PostDetail.aspx?公告編號={0}，其中{0}便是繫結了資料庫的公告編號，GridView等於自動幫你繫結好了。那麼，若是使用單獨的&lt;strong&gt;HyperLink&lt;/strong&gt;控制項，可以使用&lt;strong&gt;Eval&lt;/strong&gt;繫結寫法的方式來傳遞QueryString值。&lt;br&gt;&lt;br&gt;其寫法如下：&lt;br&gt;&amp;lt;asp:HyperLink ID="HyperLink" runat="server" &lt;br&gt;NavigateUrl=&lt;strong&gt;&lt;font color="#ff0000"&gt;'&amp;lt;%# "PostDetail.aspx?PostID=" &amp;amp; Eval("公告編號") %&amp;gt;'&lt;/font&gt;&lt;/strong&gt; &amp;gt;&lt;br&gt;&amp;lt;%# Eval("主題") %&amp;gt;&amp;lt;/asp:HyperLink&amp;gt;&lt;br&gt;&lt;br&gt;&lt;font color="#808080"&gt;※&amp;nbsp; 前提是別忘了先將欲繫結的資料欄位Select出來。&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-8152659577683248370?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/8152659577683248370/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/03/hyperlinkevalquerystring.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8152659577683248370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8152659577683248370'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/03/hyperlinkevalquerystring.html' title='HyperLink使用Eval繫結資料庫傳遞QueryString值'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_2sQfBxJU9mI/S5ZSGUCLgVI/AAAAAAAAL_Y/Ywukcgg4tNs/s72-c/2010-03-09_213050_thumb%5B3%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-5832966238671638959</id><published>2010-02-26T22:14:00.001+08:00</published><updated>2010-02-26T22:20:42.417+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>GridView中使用CommandArgument取得Button按哪一列(ListView同樣適用)</title><content type='html'>&lt;p&gt;在Asp.net中Button有個非常好使用的屬性：&lt;font color="#ff0000"&gt;&lt;strong&gt;CommandArgument&lt;br&gt;&lt;/strong&gt;&lt;font color="#000000"&gt;MSDN對&lt;a href="http://msdn.microsoft.com/zh-tw/library/system.web.ui.webcontrols.button.commandargument%28VS.80%29.aspx" target="_blank"&gt;CommandArgument&lt;/a&gt;的解釋是：取得或設定選擇性 (Optional) 參數，與相關的 CommandName 一起傳遞至 Command 事件。&lt;/font&gt;&lt;br&gt;&lt;/font&gt;配合GridView、ListView使用起來可以實現判斷點擊Button是哪一列的功能。&lt;br&gt;&lt;br&gt;要實現判斷按了哪一列有許多種不同作法，使用Button的CommandArgument屬性只是其中之一，但是我個人覺得最方便也最直覺的設定方法。&lt;br&gt;&lt;br&gt;在 Visturl Studio 中可以使用滑鼠點擊方式來設定&lt;strong&gt;CommandArgument&lt;/strong&gt;的繫結，方式如下：&lt;br&gt;&lt;br&gt;此例在GridView中使用ButtonField設置了刪除按鈕，接著我們先將其轉換為&lt;strong&gt;TemplateField&lt;/strong&gt;模式以利我們後續自定一些設定。&lt;br&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S4fXRq5SUAI/AAAAAAAAL-8/asZ5EnmtGcs/s1600-h/2010-02-26_213521%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-02-26_213521" border="0" alt="2010-02-26_213521" src="http://lh3.ggpht.com/_2sQfBxJU9mI/S4fXSkddpSI/AAAAAAAAL_A/wuuczMslJJo/2010-02-26_213521_thumb%5B1%5D.jpg?imgmax=800" width="334" height="263"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;接著點擊GridView視覺化視窗中的小箭頭 &amp;gt; 進入&lt;strong&gt;編輯樣板&lt;/strong&gt;，找到欲設定的刪除按鈕後，再點擊小箭頭 &amp;gt; &lt;strong&gt;編輯DataBinding&lt;/strong&gt;。&lt;br&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S4fXTvydQvI/AAAAAAAAL_E/Bou8wMh3X3Y/s1600-h/2010-02-26_213213%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-02-26_213213" border="0" alt="2010-02-26_213213" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S4fXUoV2-NI/AAAAAAAAL_I/yfI8g67meWo/2010-02-26_213213_thumb%5B1%5D.jpg?imgmax=800" width="289" height="176"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;重要設定在此：在DataBindings設定視窗中，要選擇&lt;font color="#ff0000"&gt;&lt;strong&gt;CommandArgument&lt;/strong&gt;&lt;/font&gt;&lt;font color="#000000"&gt;來作資料繫結的動作。接著選取欄位繫結(F)下拉選取欲繫結的選項，通常必須選擇作為等下要設定為SQL Delete 語法 Where 條件的選項。(若一開始無法選擇欄位繫結，點擊下方重新整理結構描述後即可)&lt;/font&gt;&lt;br&gt;&lt;a href="http://lh5.ggpht.com/_2sQfBxJU9mI/S4fXWOTdJ5I/AAAAAAAAL_M/I3J441ZJ2mg/s1600-h/2010-02-26_213417%5B4%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-02-26_213417" border="0" alt="2010-02-26_213417" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S4fXXLktj9I/AAAAAAAAL_Q/MmEu0DSjA4Q/2010-02-26_213417_thumb%5B2%5D.jpg?imgmax=800" width="504" height="369"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;設定完成後，GridView中刪除按鈕便會多了&lt;strong&gt;CommandArgument='&amp;lt;%# Eval("拜訪編號") %&amp;gt;'&lt;/strong&gt;這行程式碼。&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:TemplateField&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ShowHeader&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="False"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:Button&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Button2"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;CausesValidation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="False"&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #ff0000"&gt;CommandName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Delete_VI"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="刪除"&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #ff0000"&gt;OnClientClick&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;"if (confirm('您確定要刪除嗎?')==false) {return false;}"&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #ff0000"&gt;CommandArgument&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='&amp;lt;%# Eval("拜訪編號") %&amp;gt;'&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;     &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:TemplateField&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br&gt;最後在aspx.vb中以CodeBehind方式撰寫SQL的Delete程式碼：&lt;br&gt;由於GridView中可能不只存在一個按鈕，因此必須先在&lt;strong&gt;GridView_RowCommand&lt;/strong&gt;事件中先行判斷點擊的是刪除按鈕，之後才接著執行刪除的SQL動作。&lt;/p&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; GridView_RowCommand(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.Web.UI.WebControls.GridViewCommandEventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; GridView.RowCommand&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; e.CommandName = &lt;span style="color: #006080"&gt;"Delete_VI"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; strSQL &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; Cmd &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; SqlCommand&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                strSQL = &lt;span style="color: #006080"&gt;"Delete 拜訪目的 Where 拜訪編號=@拜訪編號 "&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                Cmd = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SqlCommand(strSQL, conn)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                Cmd.Parameters.Add(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SqlParameter(&lt;span style="color: #006080"&gt;"@拜訪編號"&lt;/span&gt;, SqlDbType.Int))&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                Cmd.Parameters(&lt;span style="color: #006080"&gt;"@拜訪編號"&lt;/span&gt;).Value = e.CommandArgument&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                Cmd.Connection.Open()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                Cmd.ExecuteNonQuery()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                Cmd.Cancel()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                Cmd.Connection.Close()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                conn.Dispose()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                VI_GridView.DataBind()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Catch&lt;/span&gt; ex &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Exception&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                Response.Write(ex.Message)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;其中，在SQL的Where條件使用了&lt;strong&gt;&lt;font color="#ff0000"&gt;e.CommandArgument&lt;/font&gt;&lt;/strong&gt;來取得繫結在CommandArgument上的資料作為刪除條件，即可實現在GridView刪除點擊那一列的功能。&lt;br&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;&lt;strong&gt;補充：&lt;br&gt;&lt;/strong&gt;&lt;/font&gt;&lt;font color="#000000"&gt;在ListView中使用&lt;strong&gt;CommandArgument&lt;/strong&gt;實現判斷Button點擊哪一列功能與GridView設定相同。唯一不同之處是ListView將Button的CommandName 傳遞至ItemCommand中，因此我們只需要將e.CommandArgument改寫在ItemCommand事件中即可。&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-5832966238671638959?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/5832966238671638959/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/02/gridviewcommandargumentbuttonlistview.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/5832966238671638959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/5832966238671638959'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/02/gridviewcommandargumentbuttonlistview.html' title='GridView中使用CommandArgument取得Button按哪一列(ListView同樣適用)'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_2sQfBxJU9mI/S4fXSkddpSI/AAAAAAAAL_A/wuuczMslJJo/s72-c/2010-02-26_213521_thumb%5B1%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-9149955757000351916</id><published>2010-02-25T21:17:00.001+08:00</published><updated>2010-02-25T21:24:12.274+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>CodeBehind方式設定GridView欄寬、置中</title><content type='html'>&lt;p&gt;使用GridView中內建的編輯功能預設是沒有設定欄寬的，因此會造成編輯時的TextBox將欄位撐開的問題：&lt;br&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S4Z4T_sqFDI/AAAAAAAAL-U/KHzm99S_tcM/s1600-h/2010-02-25_205559%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-02-25_205559" border="0" alt="2010-02-25_205559" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S4Z4U7UHRGI/AAAAAAAAL-Y/5tNIGTNPrkM/2010-02-25_205559_thumb%5B1%5D.jpg?imgmax=800" width="345" height="123"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;br&gt;在GridView的&lt;strong&gt;RowDataBound&lt;/strong&gt;事件中以CodeBehind設定欄位寬度與文字置中：&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; GridView_RowDataBound(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.Web.UI.WebControls.GridViewRowEventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; GridView.RowDataBound&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;'設定欄位寬度&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp; GridView.Columns(1).ItemStyle.Width = 80&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        GridView.Columns(1).ControlStyle.Width = 80&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;'設定文字置中&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&amp;nbsp; GridView.Columns(1).ItemStyle.HorizontalAlign = HorizontalAlign.Center&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;ItemStyle.Width&lt;/strong&gt;：普通模式欄位寬度&lt;br&gt;&lt;strong&gt;ControlStyle.Width&lt;/strong&gt; ：編輯模式欄位寬度&lt;br&gt;&lt;br&gt;設定後結果：&lt;br&gt;&lt;a href="http://lh5.ggpht.com/_2sQfBxJU9mI/S4Z4Vms8m_I/AAAAAAAAL-c/qGzgS-iH1Mc/s1600-h/2010-02-25_205627%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-02-25_205627" border="0" alt="2010-02-25_205627" src="http://lh3.ggpht.com/_2sQfBxJU9mI/S4Z4WnRGTVI/AAAAAAAAL-g/Hj_c3tAFgB4/2010-02-25_205627_thumb%5B1%5D.jpg?imgmax=800" width="276" height="123"&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;&lt;strong&gt;補充：&lt;br&gt;&lt;/strong&gt;&lt;/font&gt;&lt;font color="#000000"&gt;以For迴圈方式設定GridView中所有欄位寬度&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; GridView_RowDataBound(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.Web.UI.WebControls.GridViewRowEventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; GridView.RowDataBound&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; i &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;For&lt;/span&gt; i &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = 0 &lt;span style="color: #0000ff"&gt;To&lt;/span&gt; GridView.Columns.Count - 1&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            GridView.Columns(i).ItemStyle.Width = 80&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Next&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-9149955757000351916?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/9149955757000351916/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/02/codebehindgridview.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/9149955757000351916'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/9149955757000351916'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/02/codebehindgridview.html' title='CodeBehind方式設定GridView欄寬、置中'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_2sQfBxJU9mI/S4Z4U7UHRGI/AAAAAAAAL-Y/5tNIGTNPrkM/s72-c/2010-02-25_205559_thumb%5B1%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-4920354101768455216</id><published>2010-02-25T20:43:00.002+08:00</published><updated>2010-02-26T19:34:36.158+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>ListView中使用FindControl屬性找到按鈕</title><content type='html'>在ListView中使用HiddenField來記錄每筆回應編號&lt;br&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New',courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;asp:HiddenField&lt;/span&gt; &lt;span style="color: red"&gt;ID&lt;/span&gt;&lt;span style="color: blue"&gt;="RR_No"&lt;/span&gt; &lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;="server"&lt;/span&gt; &lt;span style="color: red"&gt;value&lt;/span&gt;&lt;span style="color: blue"&gt;='&amp;lt;%# Eval("回應編號") %&amp;gt;'&lt;/span&gt; &lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;接著要在ListView中加入ImageButton來實作刪除文章回應的功能：&lt;br&gt;&lt;br&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New',courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;asp:ImageButton&lt;/span&gt; &lt;span style="color: red"&gt;ID&lt;/span&gt;&lt;span style="color: blue"&gt;="DelButton"&lt;/span&gt; &lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;="server"&lt;/span&gt; &lt;span style="color: red"&gt;ImageUrl&lt;/span&gt;&lt;span style="color: blue"&gt;="~/images/icon_delete.gif"&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: red"&gt;OnClientClick&lt;/span&gt; = &lt;span style="color: blue"&gt;"if (confirm('您確定要刪除嗎?')==false) {return false;}"&lt;/span&gt; &lt;span style="color: red"&gt;CommandName&lt;/span&gt;&lt;span style="color: blue"&gt;="Delete_RR"&lt;/span&gt; &lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;重點就在如何在點擊刪除按鈕時，取得HiddenField中的回應編號，來做為刪除回應的SQL Where語法。在CodeBehind頁面ListView_ItemCommand事件中使用FindControl屬性來抓取HiddenField的值：&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; ListView_ItemCommand(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.Web.UI.WebControls.ListViewCommandEventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; ListView.ItemCommand&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; e.CommandName = &lt;span style="color: #006080"&gt;"Delete_RR"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; strSQL &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; Cmd &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; SqlCommand&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;'取得刪除哪一列&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; dataItem &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; ListViewDataItem = &lt;span style="color: #0000ff"&gt;CType&lt;/span&gt;(e.Item, ListViewDataItem)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; di &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = dataItem.DisplayIndex&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; RRNO &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;CType&lt;/span&gt;(ListView.Items(di).FindControl(&lt;span style="color: #006080"&gt;"RR_No"&lt;/span&gt;), HiddenField).Value&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;'SQL刪除語法&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;         &lt;span style="color: #008000"&gt;'......&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-4920354101768455216?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/4920354101768455216/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/02/listviewfindcontrol.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/4920354101768455216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/4920354101768455216'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/02/listviewfindcontrol.html' title='ListView中使用FindControl屬性找到按鈕'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-8945440211293566950</id><published>2010-02-25T20:14:00.002+08:00</published><updated>2010-02-25T20:16:26.958+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>Asp.Net子母視窗 - 關閉子視窗後重整母視窗</title><content type='html'>延續上一篇&lt;a href="http://tgw1029.blogspot.com/2010/02/windowsopenaspnetbutton.html" target="_blank"&gt;使用Windows.Open在Asp.net中使用Button彈出視窗(子母視窗功能)&lt;/a&gt;，若要實現關閉子視窗後重整母視窗的功能，我們可以在子視窗最後處理完畢事件的按鈕中 Ex：Button_Click 事件最後加入下列兩行Code：&lt;br /&gt;&lt;div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;"&gt;&lt;div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: green;"&gt;'重整母視窗&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;Response.Write(&lt;span style="color: #006080;"&gt;"&amp;lt;script&amp;gt;opener.location.href='Test.aspx'&amp;lt;/script&amp;gt;"&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: green;"&gt;'關閉子視窗&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;Response.Write(&lt;span style="color: #006080;"&gt;"&amp;lt;script&amp;gt;window.close();&amp;lt;/script&amp;gt;"&lt;/span&gt;)&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;需注意先執行重整母視窗後再執行關閉子視窗的Code，兩者順序不可顛倒。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-8945440211293566950?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/8945440211293566950/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/02/aspnet.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8945440211293566950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8945440211293566950'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/02/aspnet.html' title='Asp.Net子母視窗 - 關閉子視窗後重整母視窗'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-8095460495098447364</id><published>2010-02-24T20:21:00.005+08:00</published><updated>2010-02-25T20:09:30.695+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>使用Windows.Open在Asp.net中使用Button彈出視窗(子母視窗功能)</title><content type='html'>JavaScript的&lt;b&gt;windows.open&lt;/b&gt;語法可協助Asp.net的Button按鈕達到開啟彈出視窗的效果。如下圖：&lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S4UZpv-fjoI/AAAAAAAAL-M/O-3LT10m52o/s1600-h/2010-02-24_195714%5B10%5D.jpg"&gt;&lt;img alt="2010-02-24_195714" border="0" height="336" src="http://lh3.ggpht.com/_2sQfBxJU9mI/S4UZqpFjGUI/AAAAAAAAL-Q/Hn1n29-raKk/2010-02-24_195714_thumb%5B8%5D.jpg?imgmax=800" style="border: 0px none; display: inline;" title="2010-02-24_195714" width="504" /&gt;&lt;/a&gt; &lt;br /&gt;在Button的Load事件中加入如下Code：&lt;br /&gt;&lt;div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;"&gt;&lt;div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Protected&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; Button1_Load(&lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Object&lt;/span&gt;, &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: blue;"&gt;Handles&lt;/span&gt; Button1.Load&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;Button1.Attributes.Add(&lt;span style="color: #006080;"&gt;"onclick"&lt;/span&gt;, &lt;span style="color: #006080;"&gt;"window.open('Test2.aspx','','menubar=no,status=no,scrollbars=yes,top=100,left=200,toolbar=no,width=450,height=300');"&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="background-color: white; border-style: none; color: black; direction: ltr; font-family: 'Courier New',courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;在Button加上&lt;a href="http://msdn.microsoft.com/zh-tw/library/7a9d6h4f%28VS.80%29.aspx" target="_blank"&gt;&lt;b&gt;Attributes&lt;/b&gt;&lt;/a&gt;屬性為Button增加(Add)Html屬性。接著使用JavaScript語法來設定開啟新視窗的連結、視窗位置、視窗大小等屬性。&lt;br /&gt;&lt;br /&gt;&lt;b&gt;"window.open('Test2.aspx','測試','menubar=no,status=no,scrollbars=yes,top=100,left=200,toolbar=no,width=450,height=300');"&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;參數解釋：&lt;br /&gt;'Test2.aspx'&amp;nbsp; - 欲開啟網頁的連結網址&lt;br /&gt;'測試' – 視窗文件名稱&lt;br /&gt;menubar=no - 是否顯示視窗選單按鈕&lt;br /&gt;status=no - 是否顯示狀態欄位&lt;br /&gt;scrollbars=yes - 是否顯示視窗捲軸&lt;br /&gt;top=100,left=200 - 視窗起始位置&lt;br /&gt;toolbar=no - 是否顯示工具列&lt;br /&gt;width=450,height=300 - 視窗大小&lt;br /&gt;&lt;br /&gt;&lt;div style="color: blue;"&gt;2010/02/25補充：&lt;/div&gt;使用Button的&lt;b&gt;OnClientClick&lt;/b&gt;屬性也可達到同樣效果&lt;br /&gt;Button1.OnClientClick = "&lt;span style="color: black;"&gt;window.open('Test2.aspx','','menubar=no,status=no,scrollbars=yes,top=100,left=200,toolbar=no,width=450,height=300');&lt;/span&gt;"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-8095460495098447364?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/8095460495098447364/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/02/windowsopenaspnetbutton.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8095460495098447364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8095460495098447364'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/02/windowsopenaspnetbutton.html' title='使用Windows.Open在Asp.net中使用Button彈出視窗(子母視窗功能)'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_2sQfBxJU9mI/S4UZqpFjGUI/AAAAAAAAL-Q/Hn1n29-raKk/s72-c/2010-02-24_195714_thumb%5B8%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-2035531366318432152</id><published>2010-02-23T21:03:00.003+08:00</published><updated>2010-02-24T13:33:41.237+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>具有潛在危險Request.Form 的值已從用戶端偵測到(解決方法)</title><content type='html'>在Asp.Net的網站操作中，會產生『&lt;b&gt;具有潛在危險 Request.Form 的值已從用戶端偵測到&lt;/b&gt;』此錯誤訊息之原因，通常是在PostBack後系統偵測到頁面中存在某些文字輸入欄位如TextBox、Html編輯器(如FckEditor)等文字內容中存在Html語法，因而判斷為惡意程式碼，如此來避免駭客的惡意攻擊。&lt;br /&gt;&lt;br /&gt;此防禦功能在Asp.Net中預設是開啟的，可以透過在頁面的Page指示詞中加入 &lt;b&gt;&lt;span style="color: black;"&gt;validateRequest="False"&lt;/span&gt;&lt;/b&gt; 來關閉它。即可避免資料送出後系統將Html語法判斷為惡意程式碼。&lt;br /&gt;&lt;br /&gt;Ex：&lt;br /&gt;&amp;lt;%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Test" &lt;b&gt;&lt;span style="color: red;"&gt;validateRequest="False"&lt;/span&gt;&lt;/b&gt; %&amp;gt;&lt;br /&gt;&lt;br /&gt;另一種關閉方式是透過 &lt;b&gt;web.config &lt;/b&gt;設定檔來達到整個網站皆關閉防禦功能的效果。但是非常不建議直接在&lt;b&gt;web.config &lt;/b&gt;設定檔中作關閉的動作，這樣對系統的登入驗證頁面來說等於開了窗，非常危險。&lt;br /&gt;&lt;br /&gt;&lt;b&gt;web.config &lt;/b&gt;設定檔的關閉方法：&lt;br /&gt;&amp;lt;system.web&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style="color: red;"&gt;&amp;lt;pages validateRequest="False" /&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&amp;lt;/system.web&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-2035531366318432152?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/2035531366318432152/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/02/requestform.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/2035531366318432152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/2035531366318432152'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/02/requestform.html' title='具有潛在危險Request.Form 的值已從用戶端偵測到(解決方法)'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-8941550596056490619</id><published>2010-02-22T22:29:00.001+08:00</published><updated>2010-02-22T22:29:26.619+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>Asp.Net在SQL Server中使用Between在指定範圍區間中查詢</title><content type='html'>&lt;p&gt;今天實作一個功能，必須可自行設定區間來判斷客戶等級的需求。為了實現此功能作了一個簡易的測試頁面，記錄如下。&lt;br&gt;&lt;br&gt;首先需要在SQL Server資料庫中建立一個『客戶級別』Table，其內容如下圖：&lt;br&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S4KUp7NWxqI/AAAAAAAAL9c/0sfxfKgjn94/s1600-h/2010-02-22_220629%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-02-22_220629" border="0" alt="2010-02-22_220629" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S4KUqnMcSxI/AAAAAAAAL9g/4F7mcFjj3fo/2010-02-22_220629_thumb%5B1%5D.jpg?imgmax=800" width="445" height="110"&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;可以看出其Range分為三等級，各自指定了最小值、最大值。&lt;/p&gt; &lt;p&gt;接著便建立一個簡易的測試頁面來測試如何使用T-SQL的Between語法來達到輸入指定數值而抓取數值所落在的級別為何。&lt;br&gt;測試畫面與程式如下：&lt;br&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S4KUrS6EG2I/AAAAAAAAL9k/gEwErO40Ebs/s1600-h/2010-02-22_220747%5B2%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-02-22_220747" border="0" alt="2010-02-22_220747" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S4KUsZigYtI/AAAAAAAAL9o/M-DpcOUzBpA/2010-02-22_220747_thumb.jpg?imgmax=800" width="159" height="120"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Test2.aspx&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Test" %&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;!&lt;/span&gt;&lt;span style="color: #800000"&gt;DOCTYPE&lt;/span&gt; &lt;span style="color: #ff0000"&gt;html&lt;/span&gt; &lt;span style="color: #ff0000"&gt;PUBLIC&lt;/span&gt; &lt;span style="color: #0000ff"&gt;"-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;html&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="http://www.w3.org/1999/xhtml"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;head&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;title&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;title&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;head&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="form1"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:Label&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Label"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Label"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:Label&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        輸入範圍：&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:TextBox&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="TextBox"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:TextBox&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:Button&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Button1"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="測試"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;html&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Test2.aspx.vb&lt;/p&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Imports&lt;/span&gt; System.Data.SqlClient&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Imports&lt;/span&gt; System.Data&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;Partial &lt;span style="color: #0000ff"&gt;Class&lt;/span&gt; Test&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Inherits&lt;/span&gt; System.Web.UI.Page&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; myMsg &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AlertMessage&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; conn &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; SqlConnection&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; Page_Load(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Load&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        conn = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SqlConnection(ConfigurationManager.ConnectionStrings(&lt;span style="color: #006080"&gt;"TestConnectionString"&lt;/span&gt;).ConnectionString)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; Button1_Click(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; Button1.Click&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; dr &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; SqlDataReader&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; strSQL &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        conn.Open()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;'以TextBox欄位輸入的數值作為判斷條件，來比對最小值與最大值&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        strSQL = &lt;span style="color: #006080"&gt;"Select 級別 From 客戶級別 Where "&lt;/span&gt; &amp;amp; TextBox.Text &amp;amp; &lt;span style="color: #006080"&gt;" Between 最小值 And 最大值 "&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; Cmd &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SqlCommand(strSQL, conn)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        dr = Cmd.ExecuteReader&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; dr.Read &amp;lt;&amp;gt; &lt;span style="color: #0000ff"&gt;False&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Label.Text = dr(0)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        Cmd.Cancel()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        dr.Close()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        conn.Close()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        conn.Dispose()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Class&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;此隻程式中，使用T-SQL的Between來作為使用者輸入至TextBox值的範圍設定，如此即可從資料庫中Select到落在此Range範圍中的級別為何。&lt;br&gt;&lt;strong&gt;Select 級別 From 客戶級別 Where " &amp;amp; TextBox.Text &amp;amp; " Between 最小值 And 最大值&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;執行結果如下：&lt;br&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S4KUtOLlIcI/AAAAAAAAL9s/AXIYfxg7PKA/s1600-h/2010-02-22_222659%5B2%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-02-22_222659" border="0" alt="2010-02-22_222659" src="http://lh3.ggpht.com/_2sQfBxJU9mI/S4KUt8jphSI/AAAAAAAAL9w/hAW2IaaRXfs/2010-02-22_222659_thumb.jpg?imgmax=800" width="173" height="138"&gt;&lt;/a&gt; &lt;a href="http://lh5.ggpht.com/_2sQfBxJU9mI/S4KUug_gbuI/AAAAAAAAL90/gbcFY5SXX8Y/s1600-h/2010-02-22_222715%5B2%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-02-22_222715" border="0" alt="2010-02-22_222715" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S4KUvoYdh5I/AAAAAAAAL94/3hlfpafk39I/2010-02-22_222715_thumb.jpg?imgmax=800" width="181" height="138"&gt;&lt;/a&gt; &lt;a href="http://lh6.ggpht.com/_2sQfBxJU9mI/S4KUwEWT3YI/AAAAAAAAL98/m2ajR3I9W7I/s1600-h/2010-02-22_222734%5B2%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-02-22_222734" border="0" alt="2010-02-22_222734" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S4KUxD8SUUI/AAAAAAAAL-A/M6vIzK6uLp8/2010-02-22_222734_thumb.jpg?imgmax=800" width="176" height="135"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-8941550596056490619?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/8941550596056490619/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/02/aspnetsql-serverbetween.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8941550596056490619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8941550596056490619'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/02/aspnetsql-serverbetween.html' title='Asp.Net在SQL Server中使用Between在指定範圍區間中查詢'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_2sQfBxJU9mI/S4KUqnMcSxI/AAAAAAAAL9g/4F7mcFjj3fo/s72-c/2010-02-22_220629_thumb%5B1%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-8522804464880121095</id><published>2010-02-21T01:18:00.004+08:00</published><updated>2010-02-21T14:21:50.056+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>Asp.net中使用MD5碼將使用者密碼加密，簡易登入驗證測試</title><content type='html'>對於一個網站來說，保護使用者資料是最基本的要求。所謂MD5碼是一種經過加密過後的編碼，請參考：&lt;a href="http://zh.wikipedia.org/zh-tw/MD5" target="_blank"&gt;維基百科：MD5&lt;/a&gt;。&lt;br&gt;&lt;br&gt;一般看到可解讀的密碼如123稱為明碼，經過MD5編碼過後看到的123會變成：&lt;b&gt;202cb962ac59075b964b07152d234b70 &lt;/b&gt;此種顯示方式。需注意的是經過MD5編碼過後無法解碼，也就是說非經過正常方法是無法反譯的。&lt;br&gt;&lt;br&gt;其實無法解碼也沒什麼問題的，只要在驗證使用者登入時同樣使用MD5編碼將密碼欄位輸入的字元編碼過後再與資料庫進行比對即可。在Asp.Net中我寫個簡單的登入頁面作測試，其過程與結果如下：&lt;br&gt;&lt;br&gt;首先在Asp.Net中使用&lt;b&gt;FormsAuthentication.HashPasswordForStoringInConfigFile 方法&lt;/b&gt;建立 MD5 的 Public Function： &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;'MD5公用函式&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; MD5(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; str &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; code &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; code = 16 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, &lt;span style="color: #006080"&gt;"MD5"&lt;/span&gt;).ToLower().Substring(8, 16)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; code = 32 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, &lt;span style="color: #006080"&gt;"MD5"&lt;/span&gt;).ToLower()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; &lt;span style="color: #006080"&gt;"00000000000000000000000000000000"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Function&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;接著製作一個簡易的登入功能頁面來呼叫MD5函式作為測試用，畫面如下。一個&lt;b&gt;新增&lt;/b&gt;按鈕用來新增燈入帳密至資料庫；一個&lt;b&gt;登入&lt;/b&gt;按鈕來驗證使用者登入正確與否： &lt;br&gt;&lt;a href="http://lh5.ggpht.com/_2sQfBxJU9mI/S4AZNApMzlI/AAAAAAAAL80/JIqRrLcoUOE/s1600-h/2010-02-21_005119%5B2%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2010-02-21_005119" border="0" alt="2010-02-21_005119" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S4AZOAKVUsI/AAAAAAAAL84/m58wm4GcLx8/2010-02-21_005119_thumb.jpg?imgmax=800" width="223" height="114"&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;&lt;b&gt;&lt;br&gt;Default.aspx&lt;/b&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="background-color: #ffff00"&gt;&amp;lt;%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;!&lt;/span&gt;&lt;span style="color: #800000"&gt;DOCTYPE&lt;/span&gt; &lt;span style="color: #ff0000"&gt;html&lt;/span&gt; &lt;span style="color: #ff0000"&gt;PUBLIC&lt;/span&gt; &lt;span style="color: #0000ff"&gt;"-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;html&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="http://www.w3.org/1999/xhtml"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;head&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;title&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;title&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;head&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="form1"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    帳號：&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:TextBox&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="ID"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:TextBox&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    密碼：&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:TextBox&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="PW"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:TextBox&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;br&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:Button&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Login"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="登入"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #ff0000"&gt;&amp;amp;nbsp;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:Button&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="AddNew"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="server"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="新增"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;body&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;html&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;Default.aspx.vb&lt;/b&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Imports&lt;/span&gt; System.Data.SqlClient&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Imports&lt;/span&gt; System.Data&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;Partial &lt;span style="color: #0000ff"&gt;Class&lt;/span&gt; Default2&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Inherits&lt;/span&gt; System.Web.UI.Page&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; conn &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; SqlConnection&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; Page_Load(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Load&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        conn = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SqlConnection(ConfigurationManager.ConnectionStrings(&lt;span style="color: #006080"&gt;"TestConnectionString"&lt;/span&gt;).ConnectionString)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;'MD5公用函式&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; MD5(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; str &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; code &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; code = 16 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, &lt;span style="color: #006080"&gt;"MD5"&lt;/span&gt;).ToLower().Substring(8, 16)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; code = 32 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, &lt;span style="color: #006080"&gt;"MD5"&lt;/span&gt;).ToLower()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; &lt;span style="color: #006080"&gt;"00000000000000000000000000000000"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;'新增帳號&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; AddNew_Click(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; AddNew.Click&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; strSQL &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; Cmd &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; SqlCommand&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            strSQL = &lt;span style="color: #006080"&gt;" Insert Into Login(ID,PW) "&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            strSQL += &lt;span style="color: #006080"&gt;"Values(@ID,@PW) "&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Cmd = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SqlCommand(strSQL, conn)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Cmd.Parameters.Add(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SqlParameter(&lt;span style="color: #006080"&gt;"@ID"&lt;/span&gt;, SqlDbType.VarChar))&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Cmd.Parameters(&lt;span style="color: #006080"&gt;"@ID"&lt;/span&gt;).Value = ID.Text&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Cmd.Parameters.Add(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SqlParameter(&lt;span style="color: #006080"&gt;"@PW"&lt;/span&gt;, SqlDbType.VarChar))&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Cmd.Parameters(&lt;span style="color: #006080"&gt;"@PW"&lt;/span&gt;).Value = MD5(PW.Text, 32)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Cmd.Connection.Open()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Cmd.ExecuteNonQuery()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Cmd.Cancel()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Cmd.Connection.Close()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            conn.Dispose()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Response.Write(&lt;span style="color: #006080"&gt;"新增成功！&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Catch&lt;/span&gt; ex &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Exception&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Response.Write(&lt;span style="color: #006080"&gt;"新增失敗！&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Try&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;'登入按鈕&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; Login_Click(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; e &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; Login.Click&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; strSQL &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; dr &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; SqlDataReader&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        strSQL = &lt;span style="color: #006080"&gt;"Select ID,PW From Login "&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; Cmd &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SqlCommand(strSQL, conn)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        conn.Open()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        dr = Cmd.ExecuteReader&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; dr.Read &amp;lt;&amp;gt; &lt;span style="color: #0000ff"&gt;False&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #008000"&gt;'如果帳密都相符合&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ID.Text = dr(&lt;span style="color: #006080"&gt;"ID"&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;And&lt;/span&gt; MD5(PW.Text, 32) = dr(&lt;span style="color: #006080"&gt;"PW"&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                Response.Write(&lt;span style="color: #006080"&gt;"登入成功！&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                Response.Write(&lt;span style="color: #006080"&gt;"帳密不符！&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Response.Write(&lt;span style="color: #006080"&gt;"無帳號存在！&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        Cmd.Cancel()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        dr.Close()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        conn.Close()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        conn.Dispose()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Class&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;我們來新增一個登入帳號為abc、密碼123：&lt;br&gt;&lt;br&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S4AZPH6PDSI/AAAAAAAAL88/58O6mbrDPBU/s1600-h/2010-02-21_005221%5B2%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2010-02-21_005221" border="0" alt="2010-02-21_005221" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S4AZQJTsm4I/AAAAAAAAL9A/uEBYCofpgok/2010-02-21_005221_thumb.jpg?imgmax=800" width="223" height="145"&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;新增成功後，在資料庫中看到的密碼欄位便會以MD5編碼方式將123編碼為如下圖的形式：&lt;br&gt;&lt;a href="http://lh6.ggpht.com/_2sQfBxJU9mI/S4AZRGgF6MI/AAAAAAAAL9E/xVVo-sz8JMc/s1600-h/2010-02-21_005258%5B3%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2010-02-21_005258" border="0" alt="2010-02-21_005258" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S4AZSP1kYfI/AAAAAAAAL9I/1l6uTeHKkRM/2010-02-21_005258_thumb%5B1%5D.jpg?imgmax=800" width="463" height="69"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;現在可以進行登入測試了。因為在Default.aspx.vb中使用呼叫MD5函式來進行資料比對，會先將PW.Text欄位字元轉為MD5編碼&lt;br&gt;If ID.Text = dr("ID") And &lt;b&gt;&lt;span style="color: red"&gt;MD5(PW.Text, 32)&lt;/span&gt;&lt;/b&gt; = dr("PW") Then&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Response.Write("登入成功！&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;")&lt;br&gt;Else&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Response.Write("帳密不符！&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;")&lt;br&gt;End If&lt;br&gt;&lt;br&gt;試著KeyIn錯誤的密碼，系統回應帳密不符&lt;br&gt;&lt;br&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S4AZTNmvNWI/AAAAAAAAL9M/SdrxSHhmOh4/s1600-h/2010-02-21_011341%5B2%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2010-02-21_011341" border="0" alt="2010-02-21_011341" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S4AZUbcM7CI/AAAAAAAAL9Q/NWZww-8OlR0/2010-02-21_011341_thumb.jpg?imgmax=800" width="224" height="143"&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;輸入剛才新增的帳密abc、123，即可登入成功。&lt;br&gt;證明MD5已經過編碼後與資料庫欄位進行比對成功了！&lt;br&gt;&lt;br&gt;&lt;a href="http://lh6.ggpht.com/_2sQfBxJU9mI/S4AZVPWtRGI/AAAAAAAAL9U/LajWlJrmDok/s1600-h/2010-02-21_011354%5B2%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2010-02-21_011354" border="0" alt="2010-02-21_011354" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S4AZWD5bLbI/AAAAAAAAL9Y/3s7EdPMsdPM/2010-02-21_011354_thumb.jpg?imgmax=800" width="225" height="142"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-8522804464880121095?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/8522804464880121095/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/02/aspnetmd5.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8522804464880121095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8522804464880121095'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/02/aspnetmd5.html' title='Asp.net中使用MD5碼將使用者密碼加密，簡易登入驗證測試'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_2sQfBxJU9mI/S4AZOAKVUsI/AAAAAAAAL84/m58wm4GcLx8/s72-c/2010-02-21_005119_thumb.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-8769102733241771415</id><published>2010-01-29T22:37:00.004+08:00</published><updated>2010-01-31T22:38:33.096+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>如何在aspx的page中取得UserControl的值</title><content type='html'>UserControl非常適合用代替重複性高的物件，使用UserControl可以讓程式碼更簡潔，甚至在日後修改物件內容時能達到一次性的修改。我們也可以將UserControl中物件的值取出交給aspx的page頁面來使用。&lt;br /&gt;&lt;br /&gt;如下圖，我們使用一個UserControl來建立五個DropDownList，最後透過點擊Button按鈕來取得UserControl中的DropDownList的SelectedValue值，並對應至各個Label中。    &lt;br /&gt;&lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S2Lyp7u9PPI/AAAAAAAAL7w/_BOfsuRWRqE/s1600-h/2010-01-29_222109%5B2%5D.jpg"&gt;&lt;img alt="2010-01-29_222109" border="0" height="155" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S2Lyq0hX-wI/AAAAAAAAL70/Ql5v1w8Xerg/2010-01-29_222109_thumb.jpg?imgmax=800" style="border-width: 0px; display: inline;" title="2010-01-29_222109" width="143" /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;br /&gt;首先，建立好所需的UserControl控制項：     &lt;br /&gt;&lt;br /&gt;WebUserControl.ascx ：&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); min-height: 40px; overflow: auto; padding: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="background-color: yellow; color: black;"&gt;&amp;lt;%@ Control Language="VB" AutoEventWireup="false" CodeFile="WebUserControl.ascx.vb" Inherits="WebUserControl" %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;DropDownList&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;=&lt;span style="color: blue;"&gt;"DropDownList"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;ListItem&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;選項1&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;ListItem&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;ListItem&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;選項2&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;ListItem&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;ListItem&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;選項3&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;ListItem&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;ListItem&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;選項4&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;ListItem&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;ListItem&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;選項5&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;ListItem&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;DropDownList&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;WebUserControl.ascx.vb：&lt;br /&gt;此隻程式的重點，&lt;b style="color: red;"&gt;透過Public屬性達到跨網頁張貼 &lt;/b&gt;(Cross-Page Posting)&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); min-height: 40px; overflow: auto; padding: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Partial&lt;/span&gt; &lt;span style="color: blue;"&gt;Class&lt;/span&gt; WebUserControl&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Inherits&lt;/span&gt; System.Web.UI.UserControl&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'使用公開屬性將DropDownList.SelectedValue指定給GetDL()變數&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Public&lt;/span&gt; &lt;span style="color: blue;"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: blue;"&gt;Property&lt;/span&gt; GetDL() &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;String&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Get&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;GetDL = DropDownList.SelectedValue&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Get&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Property&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Class&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;Default.aspx：  &lt;br /&gt;利用UserControl建立五個控制項DropDown1~5&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); min-height: 40px; overflow: auto; padding: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="background-color: yellow; color: black;"&gt;&amp;lt;%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="background-color: yellow; color: black;"&gt;&amp;lt;%@ Register TagPrefix="Test_UC" TagName="DropDown" src="WebUserControl.ascx"%&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;html&lt;/span&gt; &lt;span style="color: red;"&gt;xmlns&lt;/span&gt;=&lt;span style="color: blue;"&gt;"http://www.w3.org/1999/xhtml"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;head&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;title&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;title&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;head&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;body&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;form&lt;/span&gt; &lt;span style="color: red;"&gt;id&lt;/span&gt;=&lt;span style="color: blue;"&gt;"form1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;div&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Test&lt;/span&gt;&lt;span style="color: red;"&gt;_UC&lt;/span&gt;:&lt;span style="color: red;"&gt;DropDown&lt;/span&gt;  &lt;span style="color: red;"&gt;id&lt;/span&gt;=&lt;span style="color: blue;"&gt;"DropDown1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Label&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;=&lt;span style="color: blue;"&gt;"Label1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: red;"&gt;Text&lt;/span&gt;=&lt;span style="color: blue;"&gt;"Label"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Label&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;br&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Test&lt;/span&gt;&lt;span style="color: red;"&gt;_UC&lt;/span&gt;:&lt;span style="color: red;"&gt;DropDown&lt;/span&gt;  &lt;span style="color: red;"&gt;id&lt;/span&gt;=&lt;span style="color: blue;"&gt;"DropDown2"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Label&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;=&lt;span style="color: blue;"&gt;"Label2"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: red;"&gt;Text&lt;/span&gt;=&lt;span style="color: blue;"&gt;"Label"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Label&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;br&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Test&lt;/span&gt;&lt;span style="color: red;"&gt;_UC&lt;/span&gt;:&lt;span style="color: red;"&gt;DropDown&lt;/span&gt;  &lt;span style="color: red;"&gt;id&lt;/span&gt;=&lt;span style="color: blue;"&gt;"DropDown3"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Label&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;=&lt;span style="color: blue;"&gt;"Label3"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: red;"&gt;Text&lt;/span&gt;=&lt;span style="color: blue;"&gt;"Label"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Label&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;br&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Test&lt;/span&gt;&lt;span style="color: red;"&gt;_UC&lt;/span&gt;:&lt;span style="color: red;"&gt;DropDown&lt;/span&gt;  &lt;span style="color: red;"&gt;id&lt;/span&gt;=&lt;span style="color: blue;"&gt;"DropDown4"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Label&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;=&lt;span style="color: blue;"&gt;"Label4"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: red;"&gt;Text&lt;/span&gt;=&lt;span style="color: blue;"&gt;"Label"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Label&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;br&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Test&lt;/span&gt;&lt;span style="color: red;"&gt;_UC&lt;/span&gt;:&lt;span style="color: red;"&gt;DropDown&lt;/span&gt;  &lt;span style="color: red;"&gt;id&lt;/span&gt;=&lt;span style="color: blue;"&gt;"DropDown5"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Label&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;=&lt;span style="color: blue;"&gt;"Label5"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: red;"&gt;Text&lt;/span&gt;=&lt;span style="color: blue;"&gt;"Label"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Label&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;br&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Button&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;=&lt;span style="color: blue;"&gt;"Button1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: red;"&gt;Text&lt;/span&gt;=&lt;span style="color: blue;"&gt;"Button"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;div&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;form&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;body&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;html&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;Default.aspx.vb：  &lt;br /&gt;在Button1_Click撰寫程式，將Label1~5對應至DropDown1~5的UserControl，並使用Public屬性GetDL取得各個UserControl的DropDownList.SelectedValue&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); min-height: 40px; overflow: auto; padding: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Partial&lt;/span&gt; &lt;span style="color: blue;"&gt;Class&lt;/span&gt; _Default&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Inherits&lt;/span&gt; System.Web.UI.Page&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Protected&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; Button1_Click(&lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Object&lt;/span&gt;, &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: blue;"&gt;Handles&lt;/span&gt; Button1.Click&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Label1.Text = DropDown1.GetDL()&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Label2.Text = DropDown2.GetDL()&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Label3.Text = DropDown3.GetDL()&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Label4.Text = DropDown4.GetDL()&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Label5.Text = DropDown5.GetDL()&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Class&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;最後程式執行的結果如下： &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/_2sQfBxJU9mI/S2Lyr-iIjjI/AAAAAAAAL74/Zwu4yo_AJG0/s1600-h/2010-01-29_223621%5B2%5D.jpg"&gt;&lt;img alt="2010-01-29_223621" border="0" height="153" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S2LyswBiSVI/AAAAAAAAL78/iSR4XSmqXIQ/2010-01-29_223621_thumb.jpg?imgmax=800" style="border-width: 0px; display: inline;" title="2010-01-29_223621" width="137" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-8769102733241771415?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/8769102733241771415/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/01/aspxpageusercontrol.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8769102733241771415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/8769102733241771415'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/01/aspxpageusercontrol.html' title='如何在aspx的page中取得UserControl的值'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_2sQfBxJU9mI/S2Lyq0hX-wI/AAAAAAAAL70/Ql5v1w8Xerg/s72-c/2010-01-29_222109_thumb.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-580603627156835724</id><published>2010-01-29T21:46:00.002+08:00</published><updated>2010-01-29T21:47:37.662+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>一次性儲存GridView中TextBox欄位文字</title><content type='html'>在GridView中將欄位轉為TemplateField的TextBox的輸入模式，非常適合資料欄位少且資料比數較固定的資料表中使用。此方法也可以一次性的將所有欄位透過For迴圈在一個儲存按鈕中一次性的Update GridView中所有TextBox欄位資料。&lt;br /&gt;&lt;br /&gt;如下圖，一個報表分類資料表，使用GridView來修改報表名稱的欄位。&lt;br /&gt;&lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S2Lmt64B0oI/AAAAAAAAL7o/9vnUxqrOGCU/s1600-h/2010-01-29_213012%5B2%5D.jpg"&gt;&lt;img alt="2010-01-29_213012" border="0" height="184" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S2LmvEuan5I/AAAAAAAAL7s/XqYh302e-Q4/2010-01-29_213012_thumb.jpg?imgmax=800" style="border-width: 0px; display: inline;" title="2010-01-29_213012" width="235" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;我們使用一個儲存按鈕(SaveAll)來一次更新全部的報表名稱欄位內容。    &lt;br /&gt;&lt;br /&gt;aspx程式碼：     &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); min-height: 40px; overflow: auto; padding: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;GridView&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;=&lt;span style="color: blue;"&gt;"FormSortGV"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: red;"&gt;AutoGenerateColumns&lt;/span&gt;=&lt;span style="color: blue;"&gt;"False"&lt;/span&gt; &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: red;"&gt;CellPadding&lt;/span&gt;=&lt;span style="color: blue;"&gt;"4"&lt;/span&gt; &lt;span style="color: red;"&gt;DataKeyNames&lt;/span&gt;=&lt;span style="color: blue;"&gt;"報表分類編號"&lt;/span&gt; &lt;span style="color: red;"&gt;DataSourceID&lt;/span&gt;=&lt;span style="color: blue;"&gt;"FormSortSQL"&lt;/span&gt; &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: red;"&gt;ForeColor&lt;/span&gt;=&lt;span style="color: blue;"&gt;"#333333"&lt;/span&gt; &lt;span style="color: red;"&gt;GridLines&lt;/span&gt;=&lt;span style="color: blue;"&gt;"None"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;RowStyle&lt;/span&gt; &lt;span style="color: red;"&gt;BackColor&lt;/span&gt;=&lt;span style="color: blue;"&gt;"#EFF3FB"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Columns&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;BoundField&lt;/span&gt; &lt;span style="color: red;"&gt;DataField&lt;/span&gt;=&lt;span style="color: blue;"&gt;"報表分類編號"&lt;/span&gt; &lt;span style="color: red;"&gt;HeaderText&lt;/span&gt;=&lt;span style="color: blue;"&gt;"編號"&lt;/span&gt; &lt;span style="color: red;"&gt;ReadOnly&lt;/span&gt;=&lt;span style="color: blue;"&gt;"True"&lt;/span&gt; &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: red;"&gt;SortExpression&lt;/span&gt;=&lt;span style="color: blue;"&gt;"報表分類編號"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;TemplateField&lt;/span&gt; &lt;span style="color: red;"&gt;HeaderText&lt;/span&gt;=&lt;span style="color: blue;"&gt;"報表名稱"&lt;/span&gt; &lt;span style="color: red;"&gt;SortExpression&lt;/span&gt;=&lt;span style="color: blue;"&gt;"報表名稱"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;TextBox&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;=&lt;span style="color: blue;"&gt;"TextBox1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: red;"&gt;Text&lt;/span&gt;=&lt;span style="color: blue;"&gt;'&amp;lt;%# Bind("報表名稱") %&amp;gt;'&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;TextBox&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;TemplateField&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Columns&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;FooterStyle&lt;/span&gt; &lt;span style="color: red;"&gt;BackColor&lt;/span&gt;=&lt;span style="color: blue;"&gt;"#507CD1"&lt;/span&gt; &lt;span style="color: red;"&gt;Font&lt;/span&gt;-&lt;span style="color: red;"&gt;Bold&lt;/span&gt;=&lt;span style="color: blue;"&gt;"True"&lt;/span&gt; &lt;span style="color: red;"&gt;ForeColor&lt;/span&gt;=&lt;span style="color: blue;"&gt;"White"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;PagerStyle&lt;/span&gt; &lt;span style="color: red;"&gt;BackColor&lt;/span&gt;=&lt;span style="color: blue;"&gt;"#2461BF"&lt;/span&gt; &lt;span style="color: red;"&gt;ForeColor&lt;/span&gt;=&lt;span style="color: blue;"&gt;"White"&lt;/span&gt; &lt;span style="color: red;"&gt;HorizontalAlign&lt;/span&gt;=&lt;span style="color: blue;"&gt;"Center"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;SelectedRowStyle&lt;/span&gt; &lt;span style="color: red;"&gt;BackColor&lt;/span&gt;=&lt;span style="color: blue;"&gt;"#D1DDF1"&lt;/span&gt; &lt;span style="color: red;"&gt;Font&lt;/span&gt;-&lt;span style="color: red;"&gt;Bold&lt;/span&gt;=&lt;span style="color: blue;"&gt;"True"&lt;/span&gt; &lt;span style="color: red;"&gt;ForeColor&lt;/span&gt;=&lt;span style="color: blue;"&gt;"#333333"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;HeaderStyle&lt;/span&gt; &lt;span style="color: red;"&gt;BackColor&lt;/span&gt;=&lt;span style="color: blue;"&gt;"#507CD1"&lt;/span&gt; &lt;span style="color: red;"&gt;Font&lt;/span&gt;-&lt;span style="color: red;"&gt;Bold&lt;/span&gt;=&lt;span style="color: blue;"&gt;"True"&lt;/span&gt; &lt;span style="color: red;"&gt;ForeColor&lt;/span&gt;=&lt;span style="color: blue;"&gt;"White"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;EditRowStyle&lt;/span&gt; &lt;span style="color: red;"&gt;BackColor&lt;/span&gt;=&lt;span style="color: blue;"&gt;"#2461BF"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;AlternatingRowStyle&lt;/span&gt; &lt;span style="color: red;"&gt;BackColor&lt;/span&gt;=&lt;span style="color: blue;"&gt;"White"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;GridView&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;SqlDataSource&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;=&lt;span style="color: blue;"&gt;"FormSortSQL"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: red;"&gt;ConnectionString&lt;/span&gt;=&lt;span style="color: blue;"&gt;"&amp;lt;%$ ConnectionStrings:ReportManageConnectionString %&amp;gt;"&lt;/span&gt; &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: red;"&gt;OldValuesParameterFormatString&lt;/span&gt;=&lt;span style="color: blue;"&gt;"original_{0}"&lt;/span&gt; &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: red;"&gt;SelectCommand&lt;/span&gt;=&lt;span style="color: blue;"&gt;"SELECT [報表分類編號], [報表名稱] FROM [報表分類]"&lt;/span&gt; &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: red;"&gt;UpdateCommand&lt;/span&gt;=&lt;span style="color: blue;"&gt;"UPDATE [報表分類] SET [報表名稱] = @報表名稱 WHERE [報表分類編號] = @original_報表分類編號"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;DeleteParameters&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Parameter&lt;/span&gt; &lt;span style="color: red;"&gt;Name&lt;/span&gt;=&lt;span style="color: blue;"&gt;"original_報表分類編號"&lt;/span&gt; &lt;span style="color: red;"&gt;Type&lt;/span&gt;=&lt;span style="color: blue;"&gt;"String"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;DeleteParameters&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;UpdateParameters&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Parameter&lt;/span&gt; &lt;span style="color: red;"&gt;Name&lt;/span&gt;=&lt;span style="color: blue;"&gt;"報表名稱"&lt;/span&gt; &lt;span style="color: red;"&gt;Type&lt;/span&gt;=&lt;span style="color: blue;"&gt;"String"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Parameter&lt;/span&gt; &lt;span style="color: red;"&gt;Name&lt;/span&gt;=&lt;span style="color: blue;"&gt;"original_報表分類編號"&lt;/span&gt; &lt;span style="color: red;"&gt;Type&lt;/span&gt;=&lt;span style="color: blue;"&gt;"String"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;UpdateParameters&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;InsertParameters&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Parameter&lt;/span&gt; &lt;span style="color: red;"&gt;Name&lt;/span&gt;=&lt;span style="color: blue;"&gt;"報表分類編號"&lt;/span&gt; &lt;span style="color: red;"&gt;Type&lt;/span&gt;=&lt;span style="color: blue;"&gt;"String"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Parameter&lt;/span&gt; &lt;span style="color: red;"&gt;Name&lt;/span&gt;=&lt;span style="color: blue;"&gt;"報表名稱"&lt;/span&gt; &lt;span style="color: red;"&gt;Type&lt;/span&gt;=&lt;span style="color: blue;"&gt;"String"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;InsertParameters&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;SqlDataSource&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: mediumvioletred;"&gt;asp&lt;/span&gt;:&lt;span style="color: maroon;"&gt;Button&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;=&lt;span style="color: blue;"&gt;"SaveAll"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;=&lt;span style="color: blue;"&gt;"server"&lt;/span&gt; &lt;span style="color: red;"&gt;Text&lt;/span&gt;=&lt;span style="color: blue;"&gt;"儲存"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;.vb的儲存按鈕SaveAll Click 事件：&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); min-height: 40px; overflow: auto; padding: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Protected&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; SaveAll_Click(&lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Object&lt;/span&gt;, &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: blue;"&gt;Handles&lt;/span&gt; SaveAll.Click&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Dim&lt;/span&gt; i &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Integer&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;For&lt;/span&gt; i = 0 &lt;span style="color: blue;"&gt;To&lt;/span&gt; FormSortGV.Rows.Count - 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;FormSortGV.UpdateRow(i, &lt;span style="color: blue;"&gt;False&lt;/span&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-580603627156835724?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/580603627156835724/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/01/gridviewtextbox.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/580603627156835724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/580603627156835724'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/01/gridviewtextbox.html' title='一次性儲存GridView中TextBox欄位文字'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_2sQfBxJU9mI/S2LmvEuan5I/AAAAAAAAL7s/XqYh302e-Q4/s72-c/2010-01-29_213012_thumb.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-2955970958043969877</id><published>2010-01-27T20:24:00.004+08:00</published><updated>2010-01-27T22:19:15.505+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Excel VBA'/><title type='text'>Excel VBA - 使用For迴圈賦予工作表(Sheets)表單控制項物件屬性</title><content type='html'>與先前文章：&lt;a href="http://tgw1029.blogspot.com/2010/01/excel-vba-for.html" target="_blank"&gt;Excel VBA - 使用For迴圈指定控制項物件屬性&lt;/a&gt;不同的是，此篇說明的控制項為工作表(Sheets)的表單控制項而非UserForm。即如何使用迴圈一次性的在&lt;b&gt;工作表&lt;/b&gt;中的賦予控制項物件屬性。&lt;br /&gt;&lt;br /&gt;我們以ComboBox控制項物件為例：    &lt;br /&gt;假設我們需要在Sheet1表單中設置40個下拉選單，每個下拉選單中含有10個選項提供使用者選取，相信大家都知道使用迴圈來實現這個需求是最適合不過的。但如何在For迴圈中利用變數來指定控制項物件屬性，才是此需求最關鍵所在。&lt;br /&gt;&lt;br /&gt;如同在UserForm中我們使用Me.Controls來使用變數指定物件的名稱一樣，在Sheets中是使用&lt;b&gt;OLEObjects&lt;/b&gt;方法來達成此需求。&lt;b&gt;OLEObjects&lt;/b&gt;方法在微軟文件中的解釋：&lt;br /&gt;&lt;br /&gt;&lt;div style="color: #6fa8dc;"&gt;&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;OLEObjects 方法&lt;/span&gt;     &lt;/b&gt;&lt;br /&gt;&lt;/div&gt;特定傳回代表圖表或工作表上單個 OLE 物件 (一個 &lt;b&gt;OLEObject&lt;/b&gt; 物件) 或所有 OLE 物件集合 (一個 &lt;b&gt;OLEObjects&lt;/b&gt; 集合) 的物件。唯讀。&lt;i&gt;expression&lt;/i&gt;&lt;b&gt;.OLEObjects(&lt;i&gt;Index&lt;/i&gt;)       &lt;br /&gt;&lt;/b&gt;&lt;i&gt;expression&amp;nbsp;&amp;nbsp; &lt;/i&gt;&amp;nbsp; 必選。傳回 &lt;b&gt;Chart&lt;/b&gt; 或 &lt;b&gt;Worksheet&lt;/b&gt; 物件的運算式。     &lt;br /&gt;&lt;b&gt;&lt;i&gt;Index&lt;/i&gt;&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 選擇性的 &lt;b&gt;Variant&lt;/b&gt;。OLE 物件的名稱或編號。     &lt;br /&gt;範例     &lt;br /&gt;此範例建立 Sheet1 上 OLE 物件的連結型態清單。該清單將出現在此範例建立的新工作表中。     &lt;br /&gt;&lt;code&gt;Set newSheet = Worksheets.Add      &lt;br /&gt;i = 2       &lt;br /&gt;newSheet.Range("A1").Value = "Name"       &lt;br /&gt;newSheet.Range("B1").Value = "Link Type"       &lt;br /&gt;For Each obj In Worksheets("Sheet1").&lt;b&gt;OLEObjects&lt;/b&gt;       &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newSheet.Cells(i, 1).Value = obj.Name       &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If obj.OLEType = xlOLELink Then       &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newSheet.Cells(i, 2) = "Linked"       &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else       &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newSheet.Cells(i, 2) = "Embedded"       &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If       &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = i + 1       &lt;br /&gt;Next&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;回到範例，我們使用&lt;b&gt;OLEObjects&lt;/b&gt;方法來設置40個下拉選單，每個下拉選單中含有10個選項提供使用者選取：&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); min-height: 40px; overflow: auto; padding: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; Worksheet_Activate()&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Dim&lt;/span&gt; i &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Integer&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;For&lt;/span&gt; i = 1 &lt;span style="color: blue;"&gt;To&lt;/span&gt; 40&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Sheet1.OLEObjects("&lt;span style="color: darkred;"&gt;Combobox&lt;/span&gt;" &amp;amp; i).List = Array("&lt;span style="color: darkred;"&gt;項目1&lt;/span&gt;", "&lt;span style="color: darkred;"&gt;項目2&lt;/span&gt;", "&lt;span style="color: darkred;"&gt;項目3&lt;/span&gt;", "&lt;span style="color: darkred;"&gt;項目4&lt;/span&gt;", "&lt;span style="color: darkred;"&gt;項目5&lt;/span&gt;", "&lt;span style="color: darkred;"&gt;項目6&lt;/span&gt;", "&lt;span style="color: darkred;"&gt;項目7&lt;/span&gt;", "&lt;span style="color: darkred;"&gt;項目8&lt;/span&gt;", "&lt;span style="color: darkred;"&gt;項目9&lt;/span&gt;", "&lt;span style="color: darkred;"&gt;項目10&lt;/span&gt;")&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;如此在Sheet1啟動後，即在Combobox1~40中各有項目1~10的選項可供選取了。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-2955970958043969877?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/2955970958043969877/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/01/excel-vba-forsheets.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/2955970958043969877'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/2955970958043969877'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/01/excel-vba-forsheets.html' title='Excel VBA - 使用For迴圈賦予工作表(Sheets)表單控制項物件屬性'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-4344591617650409374</id><published>2010-01-24T21:41:00.003+08:00</published><updated>2010-01-24T21:43:02.687+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>SQL資料庫文字資料型別的選用方法</title><content type='html'>最近開始接手設計較完整且複雜架構的系統，因此開始必需考慮資料存取效率的問題，除了資料庫的正規化外，會影響到存取效率的原因之一為資料型別的選用。&lt;br /&gt;&lt;br /&gt;在SQL中若要存取文字型態的資料，共有四種資料型別可以選擇：    &lt;br /&gt;&lt;br /&gt;&lt;table border="0" cellpadding="2" cellspacing="0" style="width: 400px;"&gt;&lt;tbody&gt;&lt;tr&gt;       &lt;td valign="top" width="133"&gt;&lt;div align="left"&gt;&lt;b&gt;資料型別&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;&lt;div align="left"&gt;&lt;b&gt;資料長度&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;&lt;b&gt;中文字所佔位元數&lt;/b&gt;&lt;br /&gt;&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="133"&gt;char(10)&amp;nbsp; &lt;br /&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;特定&lt;br /&gt;&lt;/td&gt;        &lt;td style="text-align: left;" valign="top" width="133"&gt;2&lt;br /&gt;&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="133"&gt;nchar(10) &lt;br /&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;特定&lt;br /&gt;&lt;/td&gt;        &lt;td style="text-align: left;" valign="top" width="133"&gt;1&lt;br /&gt;&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="133"&gt;varchar(10) &lt;br /&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;不特定&lt;br /&gt;&lt;/td&gt;        &lt;td style="text-align: left;" valign="top" width="133"&gt;2&lt;br /&gt;&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="133"&gt;nvarchar(10)&lt;br /&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;不特定&lt;br /&gt;&lt;/td&gt;        &lt;td style="text-align: left;" valign="top" width="133"&gt;1&lt;br /&gt;&lt;/td&gt;     &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;根據上表可以簡單的方式來判斷選擇資料欄位的型別    &lt;br /&gt;若要存取的資料是固定不變長度的欄位且無中文字，例如會員編號(5位元)，其資料型別使用 char(5)為最適選擇；若要存取的資料是不特定長度且含中文字，例如報表內容(位元長度不特定)，其資料型別使用nvarchar(max)為最識。&lt;br /&gt;&lt;br /&gt;結論：    &lt;br /&gt;1、判斷資料長度是否特定，不特定長度選用含var的資料型別varchar、nvarchar     &lt;br /&gt;2、含有中文字的內容欄位選用n開頭的資料行型別nchar、nvarchar&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-4344591617650409374?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/4344591617650409374/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/01/sql.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/4344591617650409374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/4344591617650409374'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/01/sql.html' title='SQL資料庫文字資料型別的選用方法'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-6395111683270903726</id><published>2010-01-21T20:47:00.001+08:00</published><updated>2010-01-21T20:49:51.485+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Excel VBA'/><title type='text'>Excel VBA - 讓UserForm關閉按鈕(X)失效</title><content type='html'>&lt;p&gt;由於要在開啟時實作一個登入驗證的UserForm視窗，因此想要讓右上角的關閉按鈕(X)的功能失效，來達到不通過驗證只能停在登入視窗無法進行任何其它的動作。 &lt;/p&gt;  &lt;p&gt;在網路上找到一個很簡單的設定方式，利用UserForm的QueryClose事件就可以辦到。&lt;/p&gt;  &lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 14px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; UserForm_QueryClose(Cancel &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;, CloseMode &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 14px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; CloseMode &amp;lt;&amp;gt; 1 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt; Cancel = 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 14px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-6395111683270903726?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/6395111683270903726/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/01/excel-vba-userformx.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6395111683270903726'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6395111683270903726'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/01/excel-vba-userformx.html' title='Excel VBA - 讓UserForm關閉按鈕(X)失效'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-1121891805313403211</id><published>2010-01-19T20:23:00.001+08:00</published><updated>2010-01-19T20:25:40.855+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>開啟Asp.Net網頁，出現「無法存取 IIS Metabase」</title><content type='html'>&lt;p&gt;昨日在重灌作業系統後，忘記先安裝 IIS 便直接安裝VS2008，導致後來在 IIS 架設Asp.Net網頁後一開啟首頁便出現『&lt;strong&gt;無法存取IIS Metabase&lt;/strong&gt;』的錯誤畫面。&lt;/p&gt;  &lt;p&gt;透過網路上查到的解決方法為針對IIS重新註冊Asp.Net，方法如下：   &lt;br /&gt;&lt;font color="#0000ff"&gt;&lt;font color="#333333"&gt;&lt;/font&gt;&lt;strong&gt;程式集→Microsoft Vistual Studio 2008→Vistual Studio Tools→Visual Studio 2008 命令提示字元&lt;/strong&gt;&lt;/font&gt;    &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/_2sQfBxJU9mI/S1WkPJXkRtI/AAAAAAAAL68/RHxXGshsT6M/s1600-h/2010-01-19_201711%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-01-19_201711" border="0" alt="2010-01-19_201711" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S1WkPsc2mzI/AAAAAAAAL7A/D9p6nXV6gaA/2010-01-19_201711_thumb%5B1%5D.jpg?imgmax=800" width="301" height="149" /&gt;&lt;/a&gt;     &lt;br /&gt;    &lt;br /&gt;接著直接在DOS視窗中輸入 &lt;font color="#ff0000"&gt;&lt;strong&gt;aspnet_regiis –i&lt;/strong&gt; &lt;/font&gt;&lt;font color="#000000"&gt;指令     &lt;br /&gt;看到如下圖 完成安裝後，即可成功顯示Asp.Net網頁&lt;/font&gt;    &lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S1WkQPypytI/AAAAAAAAL7E/eBHDALzcnWM/s1600-h/2010-01-19_201817%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-01-19_201817" border="0" alt="2010-01-19_201817" src="http://lh3.ggpht.com/_2sQfBxJU9mI/S1WkRD6Jp8I/AAAAAAAAL7I/CgUzhHPKLfQ/2010-01-19_201817_thumb%5B1%5D.jpg?imgmax=800" width="644" height="417" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-1121891805313403211?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/1121891805313403211/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/01/aspnet-iis-metabase.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/1121891805313403211'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/1121891805313403211'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/01/aspnet-iis-metabase.html' title='開啟Asp.Net網頁，出現「無法存取 IIS Metabase」'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_2sQfBxJU9mI/S1WkPsc2mzI/AAAAAAAAL7A/D9p6nXV6gaA/s72-c/2010-01-19_201711_thumb%5B1%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-6588825902261295164</id><published>2010-01-18T22:50:00.001+08:00</published><updated>2010-01-18T22:50:04.875+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net'/><title type='text'>在預設的設定下 SQL Server 不允許遠端連接而引起此失敗</title><content type='html'>&lt;p&gt;在VS2008資料庫總管當中加入資料時，發生錯誤訊息為：    &lt;br /&gt;&lt;em&gt;Sqlcmd:錯誤：Microsoft SQL Native Client：建立伺服器的連接時發生錯誤。連接到 SQL Server 2005 時，可能因為在預設的設定下 SQL Server 不允許遠端連接而引起此失敗。&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;解決此問題需檢查3個部分的設定    &lt;br /&gt;&lt;font color="#0000ff"&gt;一、啟動SQL Server的遠端連接&lt;/font&gt;     &lt;br /&gt;在程式集中開啟&lt;strong&gt;SQL Server 介面區組態&lt;/strong&gt;，進入&lt;strong&gt;服務和連接的介面組態&lt;/strong&gt;     &lt;br /&gt;&lt;strong&gt;&lt;a href="http://lh6.ggpht.com/_2sQfBxJU9mI/S1R1DrHH3cI/AAAAAAAAL6k/wNIspHO7k6E/s1600-h/2010-01-18_223516%5B7%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2010-01-18_223516" border="0" alt="2010-01-18_223516" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S1R1ETwPcbI/AAAAAAAAL6o/Gww-VmOntW8/2010-01-18_223516_thumb%5B5%5D.jpg?imgmax=800" width="659" height="583" /&gt;&lt;/a&gt;&lt;/strong&gt;     &lt;br /&gt;    &lt;br /&gt;在遠端連接項目選擇使&lt;strong&gt;用TCP/IP和具名管道&lt;/strong&gt;     &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S1R1FJfrfnI/AAAAAAAAL6s/bNxXJNVIhnc/s1600-h/2010-01-18_223541%5B5%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2010-01-18_223541" border="0" alt="2010-01-18_223541" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S1R1F_Ogr_I/AAAAAAAAL6w/KjPiI_y-ncg/2010-01-18_223541_thumb%5B3%5D.jpg?imgmax=800" width="640" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;二、啟動SQL Server Brower      &lt;br /&gt;&lt;font color="#000000"&gt;在SQL Server Browser項目中，將啟動類型選擇 &lt;strong&gt;自動&lt;/strong&gt; ，並點擊 &lt;strong&gt;啟動&lt;/strong&gt; 按鈕將此功能啟用。&lt;/font&gt;       &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/_2sQfBxJU9mI/S1R1GQPUcjI/AAAAAAAAL60/AANnkGWD73w/s1600-h/2010-01-18_224207%5B3%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2010-01-18_224207" border="0" alt="2010-01-18_224207" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S1R1GwGhDcI/AAAAAAAAL64/s4sx6yr2dHY/2010-01-18_224207_thumb%5B1%5D.jpg?imgmax=800" width="640" height="484" /&gt;&lt;/a&gt; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#000000"&gt;經過以上兩個設定，應該都可以成功連接了。若還是出現連接錯誤，可能是被防火牆擋住，嘗試先將你的Windows系統 or Server 防火牆、防毒軟體都先關閉再試試看能否連接成功。確定是防火牆問題的話將SQL設為例外吧     &lt;br /&gt;設定方法如下：      &lt;br /&gt;參考微軟技術支援：&lt;a title="http://support.microsoft.com/?id=914277" href="http://support.microsoft.com/?id=914277"&gt;http://support.microsoft.com/?id=914277&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;在 Windows 防火牆中建立 SQL Server 2005 的例外&lt;/strong&gt;&lt;/p&gt; 如果要在 [Windows 防火牆] 中建立 SQL Server 2005 的例外，請依照下列步驟執行：   &lt;ol&gt;   &lt;li&gt;在 [Windows 防火牆] 中，按一下 &lt;strong&gt;[例外]&lt;/strong&gt; 索引標籤，然後按一下 &lt;strong&gt;[新增程式]&lt;/strong&gt;。 &lt;/li&gt;    &lt;li&gt;在 [新增程式] 視窗中，按一下 &lt;strong&gt;[瀏覽]&lt;/strong&gt;。 &lt;/li&gt;    &lt;li&gt;按一下 C:\Program Files\Microsoft SQL Server\&lt;var&gt;MSSQL.1&lt;/var&gt;\MSSQL\Binn\sqlservr.exe 可執行程式，按一下 &lt;strong&gt;[開啟]&lt;/strong&gt;，然後按一下 &lt;strong&gt;[確定]&lt;/strong&gt;。      &lt;br /&gt;&lt;b&gt;注意&lt;/b&gt; 視 SQL Server 2005 的安裝位置而定，路徑可能有所不同。&lt;var&gt;MSSQL.1&lt;/var&gt; 是您在先前程序的步驟 3 中取得執行個體識別碼的預留位置。 &lt;/li&gt;    &lt;li&gt;針對每個需要例外的 SQL Server 2005 執行個體，重複執行步驟 1 至 3。&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;在 Windows 防火牆中建立 SQL Server Browser 服務的例外&lt;/strong&gt;&lt;/p&gt; 如果要在 [Windows 防火牆] 中建立 SQL Server Browser 服務的例外，請依照下列步驟執行：   &lt;ol&gt;   &lt;li&gt;在 [Windows 防火牆] 中，按一下 &lt;strong&gt;[例外]&lt;/strong&gt; 索引標籤，然後按一下 &lt;strong&gt;[新增程式]&lt;/strong&gt;。 &lt;/li&gt;    &lt;li&gt;在 [新增程式] 視窗中，按一下 &lt;strong&gt;[瀏覽]&lt;/strong&gt;。 &lt;/li&gt;    &lt;li&gt;按一下 C:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe 可執行程式，按一下 &lt;strong&gt;[開啟]&lt;/strong&gt;，然後按一下 &lt;strong&gt;[確定]&lt;/strong&gt;。      &lt;br /&gt;&lt;b&gt;注意&lt;/b&gt; 視 SQL Server 2005 的安裝位置而定，路徑可能有所不同。&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;font color="#000000"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-6588825902261295164?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/6588825902261295164/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/01/sql-server.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6588825902261295164'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6588825902261295164'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/01/sql-server.html' title='在預設的設定下 SQL Server 不允許遠端連接而引起此失敗'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_2sQfBxJU9mI/S1R1ETwPcbI/AAAAAAAAL6o/Gww-VmOntW8/s72-c/2010-01-18_223516_thumb%5B5%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-3795615268158264188</id><published>2010-01-15T20:42:00.002+08:00</published><updated>2010-01-15T20:43:08.809+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Excel VBA'/><title type='text'>Excel VBA - ADO連接設密碼的Access資料庫</title><content type='html'>要在VBA中使Excel連線到有加過密碼的Access時，勢必也必須在連結語法ADODB.Connection中加入通過密碼的程式碼，如下：    &lt;br /&gt;&lt;br /&gt;provider=Microsoft.Jet.OLEDB.4.0;Data Source =" &amp;amp; ThisWorkbook.Path &amp;amp; "\database.MDB;&lt;b&gt;&lt;span style="color: red;"&gt;Jet OLEDB:Database Password=YourPW&lt;/span&gt;&lt;/b&gt;"&lt;br /&gt;&lt;br /&gt;Access如何設定密碼請參考：&lt;a href="http://tgw1029.blogspot.com/2010/01/access-access.html"&gt;Access - 設定資料庫密碼(幫Access上鎖)&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-3795615268158264188?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/3795615268158264188/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/01/excel-vba-adoaccess_15.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/3795615268158264188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/3795615268158264188'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/01/excel-vba-adoaccess_15.html' title='Excel VBA - ADO連接設密碼的Access資料庫'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-3265650637163298649</id><published>2010-01-15T20:30:00.001+08:00</published><updated>2010-01-15T20:34:02.361+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access'/><title type='text'>Access - 設定資料庫密碼(幫Access上鎖)</title><content type='html'>&lt;p&gt;Acces資料庫的用途雖然較常使用在個人的電腦中，但基本的保護措施還是不可少的，若因為自己臨時離開座位也可以防止有人人士偷窺你的重要資料。&lt;/p&gt;  &lt;p&gt;可以透過Access內建的密碼功能，替資料庫設定一組自訂密碼來為Access上鎖   &lt;br /&gt;在開啟時就可以看到要求要輸入密碼的驗證了    &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S1Bf5vGZ2oI/AAAAAAAAL5k/T_K5WKy2iO4/s1600-h/2010-01-15_201203%5B2%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-01-15_201203" border="0" alt="2010-01-15_201203" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S1Bf6D7X4RI/AAAAAAAAL5o/uXBotwKLXlU/2010-01-15_201203_thumb.jpg?imgmax=800" width="205" height="116" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;設定方法：   &lt;br /&gt;&lt;strong&gt;&lt;font color="#0000ff"&gt;工具→安全性→設定資料庫密碼&lt;/font&gt;&lt;/strong&gt;    &lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S1Bf6jpsUII/AAAAAAAAL5s/gcTHuTlM8T4/s1600-h/2010-01-15_201446%5B4%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-01-15_201446" border="0" alt="2010-01-15_201446" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S1Bf7VmO_nI/AAAAAAAAL5w/ie4odl19TpU/2010-01-15_201446_thumb%5B2%5D.jpg?imgmax=800" width="644" height="462" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;不過你應該會看到如下圖的錯誤訊息視窗   &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/_2sQfBxJU9mI/S1Bf8CZdF3I/AAAAAAAAL6E/ETDoc6beop0/s1600-h/2010-01-15_201555%5B9%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-01-15_201555" border="0" alt="2010-01-15_201555" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S1Bf8lqKnZI/AAAAAAAAL6M/dd5vA2dkeRY/2010-01-15_201555_thumb%5B7%5D.jpg?imgmax=800" width="644" height="99" /&gt;&lt;/a&gt;    &lt;br /&gt;按照訊息的提示，先把資料庫關閉，從檔案功能表&lt;strong&gt;開啟舊檔&lt;/strong&gt;的方式來開啟檔案    &lt;br /&gt;，並選擇以&lt;strong&gt;&lt;font color="#ff0000"&gt;獨佔式開啟&lt;/font&gt;&lt;/strong&gt;來打開檔案    &lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S1Bf9U2FARI/AAAAAAAAL6U/THBCYKjAg2I/s1600-h/2010-01-15_201540%5B4%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="2010-01-15_201540" border="0" alt="2010-01-15_201540" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S1Bf916EdPI/AAAAAAAAL6Y/M5Khxp2tF18/2010-01-15_201540_thumb%5B2%5D.jpg?imgmax=800" width="644" height="412" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;由於資料庫有連線共用的可能性，因此這步驟只是要確定是獨立的操作使用下設定密碼。&amp;#160; &lt;br /&gt;最後再執行一次&lt;strong&gt;設定資料庫密碼&lt;/strong&gt;即可。&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-3265650637163298649?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/3265650637163298649/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/01/access-access.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/3265650637163298649'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/3265650637163298649'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/01/access-access.html' title='Access - 設定資料庫密碼(幫Access上鎖)'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_2sQfBxJU9mI/S1Bf6D7X4RI/AAAAAAAAL5o/uXBotwKLXlU/s72-c/2010-01-15_201203_thumb.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-5694700254076283119</id><published>2010-01-14T23:09:00.002+08:00</published><updated>2010-04-29T22:45:14.966+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Excel VBA'/><title type='text'>Excel VBA - 實作Listbox項目增減功能</title><content type='html'>在Excel VBA中使用&lt;strong&gt;UserForm&lt;/strong&gt;製作兩個&lt;strong&gt;ListBox&lt;/strong&gt;來達到新增、刪除項目的功能     &lt;br /&gt;實作的功能如下圖：     &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_2sQfBxJU9mI/S08zjrnTbBI/AAAAAAAAL5c/4tdEWLIAgfo/s1600-h/2010-01-14_224033%5B7%5D.jpg"&gt;&lt;img alt="2010-01-14_224033" border="0" height="255" src="http://lh5.ggpht.com/_2sQfBxJU9mI/S08zkAUFuBI/AAAAAAAAL5g/oFWqx69FMU0/2010-01-14_224033_thumb%5B3%5D.jpg?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline;" title="2010-01-14_224033" width="500" /&gt;&lt;/a&gt;     &lt;br /&gt;主要功能：     &lt;br /&gt;來源與目的ListBox選項皆有多選的功能，移至目的欄位的項目會在來源欄位中同步移除，免除使用者增加了重複的項目。 &lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'表單啟用時&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; UserForm_Activate()&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'Reset項目&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;ListBox.Clear&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Dim&lt;/span&gt; i &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Integer&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'製作10個ListBox項目&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;For&lt;/span&gt; i = 1 &lt;span style="color: blue;"&gt;To&lt;/span&gt; 10&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;ListBox.AddItem "&lt;span style="color: darkred;"&gt;項目&lt;/span&gt;" &amp;amp; i&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'增加單項(&amp;gt;)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; InButton_Click()&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'迴圈範圍List(0)~List(最後一筆)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;For&lt;/span&gt; i = 0 &lt;span style="color: blue;"&gt;To&lt;/span&gt; ListBox.ListCount - 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'若項目被選中&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;If&lt;/span&gt; ListBox.Selected(i) = &lt;span style="color: blue;"&gt;True&lt;/span&gt; &lt;span style="color: blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'項目增加至目的欄位(ResultList)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;ResultList.AddItem ListBox.List(i)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'來源欄位(ListBox)的項目數量每次減1&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;For&lt;/span&gt; i = ListBox.ListCount - 1 &lt;span style="color: blue;"&gt;To&lt;/span&gt; 0 &lt;span style="color: blue;"&gt;Step&lt;/span&gt; -1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'若項目被選中&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;If&lt;/span&gt; ListBox.Selected(i) = &lt;span style="color: blue;"&gt;True&lt;/span&gt; &lt;span style="color: blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'移除此筆來源欄位項目&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;ListBox.RemoveItem (i)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'其他按鈕的邏輯相同，不再作解釋&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'增加全部按鈕(&amp;gt;&amp;gt;)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; AllInButton_Click()&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;For&lt;/span&gt; i = 0 &lt;span style="color: blue;"&gt;To&lt;/span&gt; ListBox.ListCount - 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;ResultList.AddItem ListBox.List(i)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;For&lt;/span&gt; i = ResultList.ListCount - 1 &lt;span style="color: blue;"&gt;To&lt;/span&gt; 0 &lt;span style="color: blue;"&gt;Step&lt;/span&gt; -1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;ListBox.RemoveItem (i)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'減少單項(&amp;lt;)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; OutButton_Click()&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;For&lt;/span&gt; i = 0 &lt;span style="color: blue;"&gt;To&lt;/span&gt; ResultList.ListCount - 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;If&lt;/span&gt; ResultList.Selected(i) = &lt;span style="color: blue;"&gt;True&lt;/span&gt; &lt;span style="color: blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;ListBox.AddItem ResultList.List(i)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;For&lt;/span&gt; i = ResultList.ListCount - 1 &lt;span style="color: blue;"&gt;To&lt;/span&gt; 0 &lt;span style="color: blue;"&gt;Step&lt;/span&gt; -1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;If&lt;/span&gt; ResultList.Selected(i) = &lt;span style="color: blue;"&gt;True&lt;/span&gt; &lt;span style="color: blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;ResultList.RemoveItem i&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'減少全部(&amp;lt;&amp;lt;)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; AllOutButton_Click()&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;For&lt;/span&gt; i = 0 &lt;span style="color: blue;"&gt;To&lt;/span&gt; ResultList.ListCount - 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;ListBox.AddItem ResultList.List(i)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;For&lt;/span&gt; i = ResultList.ListCount - 1 &lt;span style="color: blue;"&gt;To&lt;/span&gt; 0 &lt;span style="color: blue;"&gt;Step&lt;/span&gt; -1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;ResultList.RemoveItem (i)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-5694700254076283119?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/5694700254076283119/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/01/excel-vba-listbox.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/5694700254076283119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/5694700254076283119'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/01/excel-vba-listbox.html' title='Excel VBA - 實作Listbox項目增減功能'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_2sQfBxJU9mI/S08zkAUFuBI/AAAAAAAAL5g/oFWqx69FMU0/s72-c/2010-01-14_224033_thumb%5B3%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-6928172411465286958</id><published>2010-01-14T22:34:00.001+08:00</published><updated>2010-01-14T22:34:18.885+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access'/><title type='text'>Access - 重置自動編號欄位數值</title><content type='html'>&lt;p&gt;Access資料表中的欄位若有使用&lt;strong&gt;自動編號&lt;/strong&gt;在經過多次的資料新增、刪除後     &lt;br /&gt;勢必已使自動編號數值處於不連號的狀態之下     &lt;br /&gt;尤其是在軟體開發人員平時所做的多次資料庫存取測試     &lt;br /&gt;在將成品交給客戶手中前，將自動編號的數值重置歸零絕對是必要的&lt;/p&gt;  &lt;p&gt;在Access中已經內建此功能按鈕，不需去額外輸入T-SQL語法    &lt;br /&gt;點擊&lt;strong&gt;&lt;font color="#0000ff"&gt;工具列→工具→資料庫公用程式→壓縮及修復資料庫        &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;如下圖，點擊後檔案自動重啟進入資料表查看自動編號已經是處於完整的連號狀態了。     &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_2sQfBxJU9mI/S08rZwH9zlI/AAAAAAAAL44/4AgdN74hzKM/s1600-h/2010-01-14_222113%5B4%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2010-01-14_222113" border="0" alt="2010-01-14_222113" src="http://lh6.ggpht.com/_2sQfBxJU9mI/S08rainAs1I/AAAAAAAAL48/yHJ_IkCNfIo/2010-01-14_222113_thumb%5B2%5D.jpg?imgmax=800" width="604" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-6928172411465286958?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/6928172411465286958/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/01/access.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6928172411465286958'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/6928172411465286958'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/01/access.html' title='Access - 重置自動編號欄位數值'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_2sQfBxJU9mI/S08rainAs1I/AAAAAAAAL48/yHJ_IkCNfIo/s72-c/2010-01-14_222113_thumb%5B2%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-5931273096670040841</id><published>2010-01-13T21:40:00.003+08:00</published><updated>2010-01-13T21:45:18.504+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Excel VBA'/><title type='text'>Excel VBA - WorkSheet新增、複製、刪除(不出現提示視窗)</title><content type='html'>&lt;b&gt;一、WorkSheet新增：&amp;nbsp;&lt;/b&gt;  &lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); min-height: 40px; overflow: auto; padding: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Sub&lt;/span&gt; TestAdd()&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'新增工作表(無任何參數)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Worksheets.Add&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'一次新增10個工作表&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Worksheets.Add Count:=10&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'新增工作表在sheet1之後&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Worksheets.Add after:=Worksheets("&lt;span style="color: darkred;"&gt;sheet1&lt;/span&gt;")&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'新增工作表在sheet1之前&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Worksheets.Add before:=Worksheets("&lt;span style="color: darkred;"&gt;sheet1&lt;/span&gt;")&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;二、WorkSheet複製：&lt;/b&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); min-height: 40px; overflow: auto; padding: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Sub&lt;/span&gt; TestCopy()&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'複製sheet1到sheet1之後&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Worksheets("&lt;span style="color: darkred;"&gt;sheet1&lt;/span&gt;").Copy After:=Worksheets("&lt;span style="color: darkred;"&gt;sheet1&lt;/span&gt;")&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'複製sheet1到sheet1之前&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Worksheets("&lt;span style="color: darkred;"&gt;sheet1&lt;/span&gt;").Copy Before:=Worksheets("&lt;span style="color: darkred;"&gt;sheet1&lt;/span&gt;")&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;三、WorkSheet刪除： &lt;br /&gt;&lt;/b&gt;在Excel中手動操作刪除動作時，會出現下圖的警告視窗&lt;br /&gt;&lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_2sQfBxJU9mI/S03NQmwX9OI/AAAAAAAAL4w/8Ipi6DmSVTU/s1600-h/2010-01-13_213503%5B4%5D.jpg"&gt;&lt;img alt="2010-01-13_213503" border="0" height="109" src="http://lh4.ggpht.com/_2sQfBxJU9mI/S03NRSHd1yI/AAAAAAAAL40/IJeptyx1X-s/2010-01-13_213503_thumb%5B2%5D.jpg?imgmax=800" style="border-width: 0px; display: inline;" title="2010-01-13_213503" width="495" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;在VBA中若要刪除工作表時，忽略此步驟需加入&lt;br /&gt;Application.DisplayAlerts = False 程式碼來關閉顯示警告視窗&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); min-height: 40px; overflow: auto; padding: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;Sub&lt;/span&gt; TestDelete&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'關閉警告視窗&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Application.DisplayAlerts = &lt;span style="color: blue;"&gt;False&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'刪除作用中的工作表&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;ActiveSheet.Delete&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;'恢復警告視窗&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;Application.DisplayAlerts = &lt;span style="color: blue;"&gt;True&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 14px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2893139382062216061-5931273096670040841?l=tgw1029.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tgw1029.blogspot.com/feeds/5931273096670040841/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://tgw1029.blogspot.com/2010/01/excel-vba-worksheet.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/5931273096670040841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2893139382062216061/posts/default/5931273096670040841'/><link rel='alternate' type='text/html' href='http://tgw1029.blogspot.com/2010/01/excel-vba-worksheet.html' title='Excel VBA - WorkSheet新增、複製、刪除(不出現提示視窗)'/><author><name>威筆記</name><uri>http://www.blogger.com/profile/03781053564980189303</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_2sQfBxJU9mI/S03NRSHd1yI/AAAAAAAAL40/IJeptyx1X-s/s72-c/2010-01-13_213503_thumb%5B2%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2893139382062216061.post-3436057405992645868</id><published>2010-01-10T00:57:00.004+08:00</published><updated>2010-01-11T11:39:13.293+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Excel VBA'/><title type='text'>Excel VBA - 使用Like運算子來設定關鍵字搜尋</title><content type='html'>先設立一個 Commond Button ，並在 Click 事件中使用 InputBox 視窗來輸入關鍵字&lt;br /&gt;來當作搜尋條件的判斷。其中 KeyWord 變數前後加上了 * 號，表示此關鍵字前後可能&lt;br /&gt;含有&lt;b&gt;零或多個字元&lt;/b&gt;。&lt;br /&gt;&lt;pre style="ba
