<?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:blogger='http://schemas.google.com/blogger/2008' 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-4798799528175341639</id><updated>2024-09-20T19:03:16.067-07:00</updated><category term="C#"/><category term="JavaScript"/><category term="jQuery"/><category term="Google API"/><category term="程式通用"/><category term="Codeigniter"/><category term="PHP"/><category term="Facebook API"/><category term="Linux"/><category term="MySQL"/><category term="Ruby On Rails"/><category term="XSL"/><title type='text'>Jayhsu&#39;s Note</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>27</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-2554029018434239137</id><published>2013-08-29T23:49:00.001-07:00</published><updated>2013-08-29T23:55:01.703-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ruby On Rails"/><title type='text'>[Ruby On Rails] 使用 Excel gem roo 時，出現 LoadError (cannot load such file -- zip/zipfilesystem) 錯誤的解決方式 </title><content type='html'>這個問題發生的原因為roo在require &#39;rubyzip&#39;時，並沒有指定rubyzip的版本。&lt;br /&gt;
&lt;br /&gt;
而rubyzip現在(2013/8/30)已更新成版本1.0.0。1.0.0就不再有zip/zip、zip/zipfilesystem 這兩個檔案。&lt;br /&gt;
&lt;br /&gt;
所以解決方法是在Gemfile加入版本指定即可：&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;
&amp;nbsp;gem &#39;rubyzip&#39;, &quot;~&amp;gt; 0.9.9&quot;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/2554029018434239137/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2013/08/ruby-on-rails-excel-gem-roo-loaderror.html#comment-form' title='3 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/2554029018434239137'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/2554029018434239137'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2013/08/ruby-on-rails-excel-gem-roo-loaderror.html' title='[Ruby On Rails] 使用 Excel gem roo 時，出現 LoadError (cannot load such file -- zip/zipfilesystem) 錯誤的解決方式 '/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-6067469190022890317</id><published>2012-01-18T17:00:00.000-08:00</published><updated>2012-01-18T17:00:41.592-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><title type='text'>(Chrome、FireFox) JavaScript設定值給TextBox時，無法觸發PostBack的一種解法</title><content type='html'>&lt;br /&gt;
如果有使用.NET 中TextBox的OnTextChanged事件，希望在TextBox的文字變動後，在Server端做一些事，通常會像下方這樣用：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;
ex. &amp;lt;asp:TextBox ID=&quot;txt1&quot; runat=&quot;server&quot; OnTextChanged=&quot;txt1_TextChanged&quot; AutoPostBack=&quot;True&quot; /&amp;gt;&lt;/div&gt;
&lt;br /&gt;
這個方式在人為操作的狀況下並不會有什麼問題，修改TextBox中的字後，會PostBack去執行程式。但如果修改TextBox中的文字，是使用JavaScript去設定值的話(ex. txt1.value = &#39;abc&#39;)，在各瀏覽器卻會有不同的結果產生，IE 會正常的執行 PostBack，但在Chrome、FireFox卻無法正常的觸發PostBack!&lt;br /&gt;
&lt;br /&gt;
在試過jQuery的一些function後(ex. bind、on、trigger)，發現還是沒辦法解決這個問題，最後只好用一個偏方來處理，使用setInterval一段時間就檢查一次TextBox的值，發現值有變動，就執行PostBack，解法如下：&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;
$(document).ready(function() { &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; //非IE才設Interval，因為IE可正常觸發&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(navigator.userAgent.indexOf(&quot;MSIE&quot;)==-1) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setInterval(&#39;detectValueChange();&#39;, 500);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
});&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
function detectValueChange() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; currentValue = $(&#39;#&amp;lt;%=txt1.ClientID%&amp;gt;&#39;).val();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; oldValue = $(&#39;#&amp;lt;%=hid1.ClientID%&amp;gt;&#39;).val();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; if (currentValue != oldValue) { &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;//使用&amp;lt;asp:HiddenField&amp;gt;暫存值，讓PostBack後，值還存在&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $(&#39;#&amp;lt;%=
hid1.ClientID%&amp;gt;&#39;).val(currentValue);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; __doPostBack(&#39;&amp;lt;%=
txt1.ClientID%&amp;gt;&#39;, &#39;&#39;); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; } &amp;nbsp; &lt;br /&gt;
} &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/6067469190022890317/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2012/01/chromefirefox-javascripttextboxpostback.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/6067469190022890317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/6067469190022890317'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2012/01/chromefirefox-javascripttextboxpostback.html' title='(Chrome、FireFox) JavaScript設定值給TextBox時，無法觸發PostBack的一種解法'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-6904187846016046531</id><published>2011-11-09T23:22:00.000-08:00</published><updated>2012-01-03T17:03:30.274-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>[C#]在有驗證控制項的狀態下幫Button加上confirm (OnClientClick +Validator)</title><content type='html'>&lt;br /&gt;
如果要對一個asp:Button控制項做再次詢問的動作(ex. 確認是否刪除? )，一般來說是可以直接這樣用：&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; font-family: Verdana; font-size: 12px; line-height: 20px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;Button&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;ID&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;btnSubmit&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;runat&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;server&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;Text&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;OK&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;onclick&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;btnSubmit_Click&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; font-family: Verdana; font-size: 12px; line-height: 20px; text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;CausesValidation&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;true&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;OnClientClick&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;return confirm(&#39;are you sure?&#39;);&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
而在有驗證控制項的狀況下，若還是用上面的return confirm方法，可是會讓驗證控制項失效的，所以要改成下列這種用法：&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; font-family: Verdana; font-size: 12px; line-height: 20px; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;Button&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;ID&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;btnSubmit&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;runat&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;server&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;Text&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;OK&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;onclick&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;btnSubmit_Click&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; font-family: Verdana; font-size: 12px; line-height: 20px; text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;CausesValidation&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;true&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;OnClientClick&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;if (Page_ClientValidate(&#39;&lt;/span&gt;&lt;span style=&quot;color: #c27ba0;&quot;&gt;[驗證群組]&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&#39;)) { return confirm(&#39;are you sure?&#39;);}&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; font-family: Verdana; line-height: 20px; text-align: left;&quot;&gt;
&lt;div style=&quot;font-size: 12px;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
其中&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #c27ba0;&quot;&gt;[驗證群組]&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt; 要記得改成你所設定的&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #c27ba0;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: red;&quot;&gt;ValidationGroup&lt;/span&gt;&lt;span style=&quot;background-color: white; color: blue; font-size: 12px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: blue; font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; font-family: Verdana; line-height: 20px; text-align: left;&quot;&gt;
&lt;div style=&quot;font-size: 12px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
參考：&lt;br /&gt;
&lt;div style=&quot;font-size: 12px;&quot;&gt;
&lt;a href=&quot;http://tim.tdaley.net/2008/12/c-onclientclick-breaks-validation.html&quot; style=&quot;font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; text-align: -webkit-auto;&quot;&gt;http://tim.tdaley.net/2008/12/c-onclientclick-breaks-validation.html&lt;/a&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/6904187846016046531/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/11/cbuttonconfirm-onclientclick-validator.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/6904187846016046531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/6904187846016046531'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/11/cbuttonconfirm-onclientclick-validator.html' title='[C#]在有驗證控制項的狀態下幫Button加上confirm (OnClientClick +Validator)'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-5110396732300991051</id><published>2011-11-01T20:18:00.000-07:00</published><updated>2011-11-01T20:19:31.158-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Google API"/><title type='text'>Google Analytics API called by C#</title><content type='html'>這是可以透過Google Analytics API 去抓出你網站的拜訪資料的功能，主要是送一個Request，再接收XML檔案，下面分兩段說明，首先是抓回XML的部份，：&lt;br /&gt;
(以下內容是參考&amp;nbsp;&lt;a href=&quot;http://www.dotblogs.com.tw/lastsecret/archive/2010/10/06/18157.aspx&quot;&gt;http://www.dotblogs.com.tw/lastsecret/archive/2010/10/06/18157.aspx&lt;/a&gt;&amp;nbsp;)&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;
private void GetXml() { &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;//送出request的網址&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var request = (HttpWebRequest)HttpWebRequest.Create(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //在這是取國家的訪客數，參數可參考&lt;a href=&quot;http://code.google.com/intl/zh-TW/apis/analytics/docs/gdata/gdataReferenceDataFeed.html#maxResults&quot;&gt;http://code.google.com/intl/zh-TW/apis/analytics/docs/gdata/gdataReferenceDataFeed.html#maxResults&lt;/a&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string.Format(&quot;https://www.google.com/analytics/feeds/data?&quot;+ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ids=ga%3A{0}&amp;amp;dimensions=ga%3Acountry&quot; +&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;&amp;amp;metrics=ga%3Avisits&amp;amp;&quot; +&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;start-date={1}&amp;amp;end-date={2}&amp;amp;sort=-ga%3Avisits&amp;amp;max-results=10&quot;,&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;12345678&quot;, &amp;nbsp;//Google Analytics 網站的ID&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;2011-09-24&quot;,&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; DateTime.Now.ToString(&quot;yyyy-MM-dd&quot;)));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //在header必須帶入token，token的取得請看下方的方法&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; request.Headers.Add(&quot;Authorization&quot;, &quot;GoogleLogin auth=&quot; + GetAuthToken());&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var response = request.GetResponse();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var responseContent = new StreamReader(response.GetResponseStream()).ReadToEnd();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //抓到XML, 存到暫存資料夾&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; StreamWriter rd = File.CreateText(Server.MapPath(&quot;~/TempFile&quot;) + @&quot;\Analytics_Country.xml&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rd.Write(responseContent);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rd.Flush();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (Exception ex) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Javascript.Alert(this.Page, &quot;Error：&quot; + ex.ToString());&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
private static string GetAuthToken() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var postContent = string.Format(@&quot;accountType=GOOGLE&amp;amp;Email={0}&amp;amp;Passwd={1}&amp;amp;service=analytics&amp;amp;source={2}&quot;,&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;Account&quot;, //Google 同號&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;PWD&quot;, //Google 密碼&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;1234&quot;//隨便&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; );&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; byte[] bPostData = Encoding.ASCII.GetBytes(postContent);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //參數與用法&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //參考http://code.google.com/intl/zh-TW/apis/accounts/docs/AuthForInstalledApps.html&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(&quot;https://www.google.com/accounts/ClientLogin&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; req.Method = &quot;POST&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; req.ContentType = &quot;application/x-www-form-urlencoded&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; req.ContentLength = bPostData.Length;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var reqStream = new StreamWriter(req.GetRequestStream());&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; reqStream.Write(postContent);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; reqStream.Flush();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HttpWebResponse rep = (HttpWebResponse)req.GetResponse();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; StreamReader repStream = new StreamReader(rep.GetResponseStream(), Encoding.UTF8);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string ctx = repStream.ReadToEnd();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //送出的response抓取token的值&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return Regex.Split(ctx, &quot;Auth=&quot;, RegexOptions.IgnoreCase)[1];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; } &amp;nbsp;&lt;/div&gt;
再來是抓XML中的資料：&lt;br /&gt;
(以下內容是參考&lt;a href=&quot;http://www.reimers.dk/jacob-reimers-blog/added-google-analytics-reader-for-net&quot;&gt;http://www.reimers.dk/jacob-reimers-blog/added-google-analytics-reader-for-net&lt;/a&gt;)&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;
protected void GetData(object sender, EventArgs e) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //讀XML檔案&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; XDocument xmlDoc = XDocument.Load(Server.MapPath(&quot;~/TempFile&quot;) + &quot;/Analytics_Country.xml&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; XNamespace defaultSpace = xmlDoc.Root.GetDefaultNamespace();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; XNamespace dxpSpace = xmlDoc.Root.GetNamespaceOfPrefix(&quot;dxp&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //LINQ &amp;nbsp;XML &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var datas = from entry in xmlDoc.Root.Descendants(defaultSpace + &quot;entry&quot;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; select new {&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; &amp;nbsp; Country = entry.Element(dxpSpace + &quot;dimension&quot;).Attribute(&quot;value&quot;).Value,&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; &amp;nbsp; Value = entry.Element(dxpSpace + &quot;metric&quot;).Attribute(&quot;value&quot;).Value&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach (var entry in datas) { &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Response.Write(&quot;Country:&quot; + entry.Country);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Response.Write(&quot;Visits: &quot; + entry.Value + &quot;&amp;lt;br /&amp;gt;&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //datas.ToDictionary&amp;lt;string, int&amp;gt;(m =&amp;gt; m.Country, m =&amp;gt; m.Value);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/5110396732300991051/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/11/google-analytics-api-called-by-c.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/5110396732300991051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/5110396732300991051'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/11/google-analytics-api-called-by-c.html' title='Google Analytics API called by C#'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-1494401759383274516</id><published>2011-08-29T06:13:00.000-07:00</published><updated>2011-08-29T06:16:04.588-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><title type='text'>ASP.NET的WebService + autocomplete + tagit 合體</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;在使用Google+、Facebook時，會常常看到Tag這個東西，這東西在使用上，很方便，而且長的還蠻好看的，我很喜歡這操作很直覺的東西，所以上網找了些plugin，並拿來實作，而我找了 &lt;a href=&quot;https://github.com/aehlke/tag-it&quot;&gt;tagit&lt;/a&gt; 這個plugin，還算簡單使用(而且我認為這是我找的 plugin 當中最漂亮的...)。&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;一般的使用很簡單，照著&amp;nbsp;&lt;a href=&quot;https://github.com/aehlke/tag-it&quot;&gt;tagit&lt;/a&gt;&amp;nbsp;的&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: #f8f8f8; font-family: helvetica, arial, freesans, clean, sans-serif; line-height: 20px;&quot;&gt;example就可以用了，但是一般的tag通常都會加上自動完成(AutoComplete)功能，所以不加個AutoComplete感覺就很弱，下面就提供個範例是用C#的WebService來實作AutoComplete功能(PHP很簡單，下面會提到一點)：&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: #f8f8f8; font-family: helvetica, arial, freesans, clean, sans-serif; line-height: 20px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;1.在WebService部份，我們用DataTable來傳回傳，所以可以在asmx.cs這樣寫：&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;[WebMethod]&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public DataTable GetList(string prefixText)&amp;nbsp;{ &amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;DataTable dt = new DataTable();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //從資料庫查詢資料的語法，請自發揮...&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // ......略&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return dt; &amp;nbsp; &amp;nbsp;//最後return一個DataTable&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;2.在aspx部份，用一個TextBox：&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;asp:TextBox ID=&quot;txtTag&quot; &amp;nbsp;runat=&quot;server&quot; autocomplete=&quot;off&quot; &amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;3.再來就是JavaScript的實作了，通常是在document.ready時實作&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;$(document).ready(function() {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; $(&quot;#&amp;lt;% =txtTag.ClientID %&amp;gt;&quot;).tagit({&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; allowSpaces: true,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tagSource: function(request, response) {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $.ajax({&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; url: &quot;/GetList.asmx/GetList&quot;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//步驟1的WebService網址及Function名稱&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; data: { prefixText: request.term },&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt; //要傳入WebService Function的變數，這裡是用來抓user所輸入的內容&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dataType: &quot;xml&quot;, &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//dataType設成Xml，php直接用json，再搭配json_encode來產生資料就可以了&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; type: &quot;POST&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; contentType: &quot;application/x-www-form-urlencoded; charset=utf-8&quot;, &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//這裡很重要，要把contentType改成WebService預設回傳的application/x-www-form-urlencoded&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dataFilter: function(data) { return data; },&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; success: function(data) { &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//成功抓到資料後，要執行的動作&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; response($.map($(data).find(&quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[欄位名稱]&lt;/span&gt;&quot;), function(item) { &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//因為是XML所以用這個方式來取資料，[欄位名稱]請記得更改成DataTable的欄位名稱&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return { value: $(item).text() }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }));&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; error: function(XMLHttpRequest, textStatus, errorThrown) {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alert(textStatus + &quot;:&quot; + errorThrown); &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//Debug用&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; });&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;4.AutoComplete的部份完成！&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;5.如果要再龜毛點，限制使用者必須輸入DataTable中的內容的話，就在JavaScript中先加入這一段：&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;$.expr[&#39;:&#39;].textEquals = function(a, i, m) {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return $(a).text().match(&quot;^&quot; + m[3] + &quot;$&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;6.再來改一下document.ready中tagit的部份，加入onTagAdded 的事件。&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;7.最後還要為tagit所產生的text加入change事件。&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;6+7後的JavaScript如下：&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #a64d79; font-size: x-small;&quot;&gt;$(document).ready(function() {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0;&quot;&gt;$(&quot;#&amp;lt;%=txtTag.ClientID %&amp;gt;&quot;).tagit({&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; allowSpaces: true,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tagSource: function(request, response) {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $.ajax({&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; url: &quot;/GetList.asmx/GetList&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; data: { prefixText: request.term },&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dataType: &quot;xml&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; type: &quot;POST&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; contentType: &quot;application/x-www-form-urlencoded; charset=utf-8&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dataFilter: function(data) { return data; },&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; success: function(data) {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; response($.map($(data).find(&quot;[欄位名稱]&quot;), function(item) {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return { value: $(item).text() }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }));&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; error: function(XMLHttpRequest, textStatus, errorThrown) {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alert(textStatus + &quot;:&quot; + errorThrown);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #c27ba0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; onTagAdded: function(event, tag) { &amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//注意！別在這alert東西，不然會執行兩次&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //.ui-autocomplete、tagit-label&amp;nbsp;是tagit執行後預設的class&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($(&quot;.ui-autocomplete li:textEquals(&#39;&quot; + tag.find(&quot;.tagit-label&quot;).text() + &quot;&#39;)&quot;).size() == 0) {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; that.removeTag(tag); &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//若輸入的內容不在資料庫中，則移除tag&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; });&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; $(&quot;.tagit input&quot;).change(function() {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($(&quot;.tagit li:textEquals(&#39;&quot; + $(this).val() + &quot;&#39;)&quot;).size() == 0) {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $(this).val(&#39;&#39;); &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//若輸入的內容不在資料庫中，則清空TextBox的內容&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; });&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #a64d79; font-size: x-small;&quot;&gt;});&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;8. 再次大功告成&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;參考資料：&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/2587378/how-to-implement-mustmatch-and-selectfirst-in-jquery-ui-autocomplete&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;http://stackoverflow.com/questions/2587378/how-to-implement-mustmatch-and-selectfirst-in-jquery-ui-autocomplete&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/aehlke/tag-it&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;https://github.com/aehlke/tag-it&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;a href=&quot;http://jqueryui.com/demos/autocomplete/&quot;&gt;http://jqueryui.com/demos/autocomplete/&lt;/a&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/1494401759383274516/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/08/aspnetwebservice-autocomplete-tagit.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/1494401759383274516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/1494401759383274516'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/08/aspnetwebservice-autocomplete-tagit.html' title='ASP.NET的WebService + autocomplete + tagit 合體'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-4390760125189119742</id><published>2011-08-29T05:24:00.000-07:00</published><updated>2011-08-29T05:24:32.043-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>UserControl 提供事件給網頁(Parent Page)觸發的方式</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;最近在弄一個讓 UserControl 提供事件給網頁呼叫的東西&lt;/span&gt;&lt;/span&gt;，&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: x-small; line-height: 18px;&quot;&gt;下面就提供一個範例，來讓UserControl中的 GridView的 RowSelecting 事件提供給網頁(Parent Page)觸發&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;1.首先，在UserControl的&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;ascx.cs中，宣告一個事件:&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;public event EventHandler PublicRowSelecting;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt; 2.再來還是在UserControl的ascx.cs中，讓原本的GridView RowSelecting的事件，執行剛剛宣告的事件PublicRowSelecting：&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;protected void gvMain_RowSelecting(object sender, GridViewSelectEventArgs e) {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.PublicRowSelecting(this, new EventArgs());&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
}&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;3.接下來就是在網頁中使用了，在網頁(Parent Page)的&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;aspx.cs 直接設定事件&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;UserControl1.PublicRowSelecting += new EventHandler(UserControl1_PublicRowSelecting);&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;4.&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black; font-family: &#39;Times New Roman&#39;; font-size: small; line-height: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;UserControl1&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;PublicRowSelecting 是你要執行的程式，這個範例只要 Response.Write就好了&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;protected void&amp;nbsp;UserControl1_PublicRowSelecting(object sender, EventArgs e) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; Response.Write(&quot;Test OK&quot;);&lt;br /&gt;
}&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;5.大功告成，接下來只要執行到 UserControl中GridView的RowSelecting事件，就會執行&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;UserControl1&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;PublicRowSelecting了。&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/4390760125189119742/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/08/usercontrol-parent-page.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/4390760125189119742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/4390760125189119742'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/08/usercontrol-parent-page.html' title='UserControl 提供事件給網頁(Parent Page)觸發的方式'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-4643663834210824857</id><published>2011-08-23T17:09:00.000-07:00</published><updated>2011-08-23T17:11:31.637-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>.Net Web Service Internal Server Error 錯誤處理方式</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
在.Net 使用Web Service的方式很簡單，只要使用下列code就可以使用&lt;br /&gt;
&lt;br /&gt;
首先在aspx加上如下程式：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&amp;lt;asp:ScriptManager runat=&quot;server&quot; ID=&quot;ScriptManager1&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;Services&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;asp:ServiceReference Path=&quot;~/AAA.asmx&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/Services&amp;gt;&lt;br /&gt;
&amp;lt;/asp:ScriptManager&amp;gt;&lt;/div&gt;JavaScript即可用下列方式使用：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;Class名稱.function名稱(參數, 完成時執行的function名稱, 錯誤時執行的function名稱, TimeOut時執行的function名稱);&lt;/div&gt;ex. &lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;AAA.funAAA(strB,&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 14px; line-height: 18px; white-space: pre;&quot;&gt;OnComplete, OnError, OnTimeOut)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
但若出現「Internal Server Error」，往往會讓人摸不著頭緒，很難找原因。在這提供幾個參考的debug方式：&lt;br /&gt;
&lt;br /&gt;
1.先檢查程式中Web Service的路徑(URL)是否有錯誤，相對路徑與絕對路徑的使用是否都抓到asmx檔案。&lt;br /&gt;
&lt;br /&gt;
2.Web Service是否有正確回傳資料，可直接打上網址 (ex. http://localhost/AAA.asmx) 並直接輸入參數檢查資料是否正確，或是否有錯誤發生。&lt;br /&gt;
&lt;br /&gt;
3.若WebService 無法用遠端存取，只可在本機(Local)存取 ，則要在web.config加上下列藍色的部份：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;system.web&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f31e0b;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;lt;webServices&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;protocols&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;add name=&quot;HttpPost&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;add name=&quot;HttpGet&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/protocols&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/webServices&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/system.web&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/4643663834210824857/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/08/net-web-service-internal-server-error.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/4643663834210824857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/4643663834210824857'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/08/net-web-service-internal-server-error.html' title='.Net Web Service Internal Server Error 錯誤處理方式'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-4330750398062819269</id><published>2011-08-16T06:36:00.000-07:00</published><updated>2011-08-16T06:36:54.906-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>ASP.NET Page Life Cycle 圖</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;最近在找一些有關ASP.NET Page的 Life Cycle的資料，看到了這張MSDN提供的圖(應該是Lag了很久...)，覺得這張圖表達的很清楚，所以貼上來，當作自已的備忘錄，參考看看。&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhuyTl2ltxloipDWMX2a9AgC86qdwy7ZYawfS6YvDD9m0gcd9dhkxTTgYwkRmT2g6hGW9hoacG__u1qYOAsknkEXiQY43S4nTjSWddp3BTgINDHBiQezG87RSCvsHHkmLqmCZJsmJ4NkxZ/s1600/ASPNET_LifeCycleOverview.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhuyTl2ltxloipDWMX2a9AgC86qdwy7ZYawfS6YvDD9m0gcd9dhkxTTgYwkRmT2g6hGW9hoacG__u1qYOAsknkEXiQY43S4nTjSWddp3BTgINDHBiQezG87RSCvsHHkmLqmCZJsmJ4NkxZ/s640/ASPNET_LifeCycleOverview.png&quot; width=&quot;515&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
轉載資料：&lt;a href=&quot;http://blogs.msdn.com/b/aspnetue/archive/2010/01/14/asp-net-page-life-cycle-diagram.aspx&quot;&gt;http://blogs.msdn.com/b/aspnetue/archive/2010/01/14/asp-net-page-life-cycle-diagram.aspx&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/4330750398062819269/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/08/aspnet-page-life-cycle.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/4330750398062819269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/4330750398062819269'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/08/aspnet-page-life-cycle.html' title='ASP.NET Page Life Cycle 圖'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhuyTl2ltxloipDWMX2a9AgC86qdwy7ZYawfS6YvDD9m0gcd9dhkxTTgYwkRmT2g6hGW9hoacG__u1qYOAsknkEXiQY43S4nTjSWddp3BTgINDHBiQezG87RSCvsHHkmLqmCZJsmJ4NkxZ/s72-c/ASPNET_LifeCycleOverview.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-8589172281015326367</id><published>2011-07-27T06:00:00.000-07:00</published><updated>2011-07-27T06:00:07.334-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>C#將DataTable做Group By並取SUM、AVG、COUNT的方法(不用LINQ)</title><content type='html'>LINQ是個很方便的東西，但在比較舊的環境(.Net Framerwork 3.0以下的版本)，是沒辦法使用LINQ的，這時要將DataTable做Group By可是很麻煩的一件事，下面就提供範例：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;DataTable dt = new DataTable(); &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;//原來的資料&lt;/span&gt;&lt;br /&gt;
dt = Get(); &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;//取得資料，PS. Get()是我自己寫的Function，要記得換成你取得DataTable的function&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;//將原來的DataTable做Distinct並複製到新DataTable，ToTable的第一個參數是設定是否&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;//要做Distinct，當然要設成true，其他參數是要做Group By的欄位名稱&lt;/span&gt;&lt;br /&gt;
DataTable dtGroup = dt.DefaultView.ToTable(true, &quot;column1&quot;, &quot;column2&quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;//開始加欄位&lt;/span&gt;&lt;br /&gt;
dtGroup.Columns.Add(&quot;CountColumn&quot;);&lt;br /&gt;
dtGroup.Columns.Add(&quot;SumColumn&quot;);&lt;br /&gt;
dtGroup.Columns.Add(&quot;AvgColumn&quot;);&lt;br /&gt;
&lt;br /&gt;
int count = 0;&lt;br /&gt;
&lt;br /&gt;
for (int i = 0; i &amp;lt; dtGroup.Rows.Count;i++)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;//取資料，用String是因為上方加欄位時，沒指定型別為數字&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;string strCount = dt.Select(&quot;column1=&#39;&quot; + dtGroup.Rows[i][&quot;column1&quot;].ToString() + &quot;&#39;&quot;).Length.ToString(); &lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;string strSum = dt.Compute(&quot;SUM(column3)&quot;, &quot;column1=&#39;&quot; + dtGroup.Rows[i][&quot;column1&quot;].ToString() + &quot;&#39;&quot;).ToString();&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;string strAvg = dt.Compute(&quot;AVG(column4)&quot;, &quot;column1=&#39;&quot; + dtGroup.Rows[i][&quot;column1&quot;].ToString() + &quot;&#39;&quot;).ToString();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;//設定資料&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;dtGroup.Rows[i][&quot;CountColumn&quot;] = (strCount&amp;nbsp;== &quot;&quot; ? &quot;0&quot; :&amp;nbsp;strCount);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;dtGroup.Rows[i][&quot;SumColumn&quot;] = (strSum&amp;nbsp;== &quot;&quot; ? &quot;0&quot; :&amp;nbsp;strSum);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;dtGroup.Rows[i][&quot;AvgColumn&quot;] = (strAvg&amp;nbsp;&amp;nbsp;== &quot;&quot; ? &quot;0&quot; :&amp;nbsp;strAvg&amp;nbsp;);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
}&lt;/div&gt;&lt;div&gt;最後dtGroup就是Group By後的資料了。&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/8589172281015326367/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/07/cdatatablegroup-bysumavgcountlinq.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/8589172281015326367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/8589172281015326367'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/07/cdatatablegroup-bysumavgcountlinq.html' title='C#將DataTable做Group By並取SUM、AVG、COUNT的方法(不用LINQ)'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-6271030444154317928</id><published>2011-07-27T05:38:00.000-07:00</published><updated>2011-07-27T05:38:55.085-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><title type='text'>用jQuery取得RadioButtonList所選的值</title><content type='html'>開發.NET程式時，常常會使用到RadioButtonList控制項，在很多狀況下常需要依照使用者所選的值去做一些判斷或動作，雖然.Net本身就有OnSelectedIndexChanged事件可以用，搭配UpdatePanel等，可以做到不用PostBack的功能，但用jQuery也是可以寫的很簡單。&lt;br /&gt;
&lt;br /&gt;
若使用的是RadioButtonList控制項，aspx內容如下：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 14px; line-height: 18px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;lt;asp:RadioButtonList ID=&quot;rblTest&quot; runat=&quot;server&quot; &amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;asp:ListItem Text=&quot;1&quot; Value=&quot;1&quot; Selected=&quot;True&quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;asp:ListItem Text=&quot;2&quot; Value=&quot;2&quot; /&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;lt;/asp:RadioButtonList&amp;gt;&lt;/span&gt;&lt;/div&gt;產生的Html語法會長成這個樣子：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;table id=&quot;rblTest&quot; border=&quot;0&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;td&amp;gt;&amp;lt;input id=&quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;rblTest_0&lt;/span&gt;&quot; type=&quot;radio&quot; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;name=&quot;rblTest&quot;&lt;/span&gt; value=&quot;1&quot; checked=&quot;checked&quot; /&amp;gt;&amp;lt;label for=&quot;rblTest_0&quot;&amp;gt;1&amp;lt;/label&amp;gt;&amp;lt;/td&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;td&amp;gt;&amp;lt;input id=&quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;rblTest_1&lt;/span&gt;&quot; type=&quot;radio&quot; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;name=&quot;rblTest&quot;&lt;/span&gt; value=&quot;2&quot; /&amp;gt;&amp;lt;label for=&quot;rblTest_1&quot;&amp;gt;2&amp;lt;/label&amp;gt;&amp;lt;/td&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;&lt;/div&gt;有看到吧? 產生的input物件，name 都是 rbTest，但id卻是以rbTest_開頭，再加上從0開始的序號，所以如果要使用jQuery取得所選的值的話，可以有兩種方法：&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;1.用id開頭取得：&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;$(&quot;input[id^=&#39;&amp;lt;% =rblTest.ClientID %&amp;gt;&#39;]:checked&quot;).val()&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;2.用name取得：&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;$(&quot;input[name=&#39;&amp;lt;% =rblTest.ClientID %&amp;gt;&#39;]:checked&quot;).val()&lt;/div&gt;兩種都可以試試。</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/6271030444154317928/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/07/jqueryradiobuttonlist.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/6271030444154317928'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/6271030444154317928'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/07/jqueryradiobuttonlist.html' title='用jQuery取得RadioButtonList所選的值'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-2709886978648074618</id><published>2011-07-15T07:00:00.000-07:00</published><updated>2011-07-15T07:00:04.479-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MySQL"/><title type='text'>MySQL使用暫存table時出現Error Code: 1137 Can&#39;t reopen table: &#39;XXX&#39;錯誤</title><content type='html'>在MySQL使用暫存Table時，若出現&amp;nbsp;Error Code: 1137 Can&#39;t reopen table: &#39;XXX&#39; 的錯誤&lt;br /&gt;
&lt;div&gt;表示你使用了像下列的語法：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;CREATE TEMPORARY TABLE &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;tempTable&lt;/span&gt;&lt;br /&gt;
SELECT * FROM tableA&lt;br /&gt;
&lt;br /&gt;
INSERT INTO&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;tempTable&lt;/span&gt;&lt;br /&gt;
SELECT *&amp;nbsp;FROM tableB&lt;br /&gt;
WHERE&amp;nbsp;tableB.`cname` IN (SELECT `cname` FROM&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;tempTable&lt;/span&gt;);&lt;/div&gt;MySQL中，是不允許一段語法裡，做出像是遞迴的動作的語法，其他資料庫我沒試過，所以不知道可不可以這樣做，而會出現這種錯誤，通常都是因為疏忽(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cccccc; font-size: x-small;&quot;&gt;就是在說我自已…= =&lt;/span&gt;)，建議解決方式：再用一個暫存Table來存原本暫存Table的值，如下：&lt;/div&gt;&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;CREATE TEMPORARY TABLE tempTable&lt;br /&gt;
SELECT * FROM tableA&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;CREATE TEMPORARY TABLE tempTable2&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;SELECT * FROM&amp;nbsp;tempTable&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
INSERT INTO&amp;nbsp;tempTable&lt;br /&gt;
SELECT *&amp;nbsp;FROM tableB&lt;br /&gt;
WHERE&amp;nbsp;tableB.`cname` IN (SELECT `cname` FROM&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;tempTable2&lt;/span&gt;);&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/2709886978648074618/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/07/mysqltableerror-code-1137-cant-reopen.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/2709886978648074618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/2709886978648074618'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/07/mysqltableerror-code-1137-cant-reopen.html' title='MySQL使用暫存table時出現Error Code: 1137 Can&#39;t reopen table: &#39;XXX&#39;錯誤'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-6112804456984348174</id><published>2011-07-15T06:09:00.000-07:00</published><updated>2012-04-17T18:44:30.103-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><title type='text'>當 $(document).ready 碰上UpdatePanel</title><content type='html'>在 ASP.NET的開發中，UpdatePanel 是一個讓人又愛又恨的存在，讓人很方便使用，卻又常會造成一些問題。其中一個問題就是當UpdatePanel的(Partial) PostBack觸發後，你會發現你在$(document).ready中所設定的事件、屬性、ccs…等，全部都消失了，畫面並沒有reload，但你設定的動畫、mouseover、mouseout、watermark…等，卻都失效，沒有作用了。下面就是為了應對這種問題的解決方式：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 10px; margin-right: 10px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;
$(document).ready(function() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;pageLoad();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;nbsp;Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function() {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pageLoad();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;});&lt;/span&gt;&lt;br /&gt;
});&lt;br /&gt;&lt;br /&gt;function pageLoad() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //你要執行的程式碼&lt;br /&gt;
}&lt;/div&gt;
加入&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-family: monospace; font-size: 14px; line-height: 18px;&quot;&gt;Sys.WebForms.PageRequestManager.getInstance().add_endRequest&amp;nbsp;&lt;/span&gt;這個事件，並重新執行一次原本$(document).ready所執行的程式就可以解決這個問題了。&lt;br /&gt;
&lt;br /&gt;
如果你要在UpdatePanel的(Partial) PostBack執行前，去處理一些事件，像是記錄當下的數值之類的，你可以用&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-family: monospace; font-size: 14px; line-height: 18px;&quot;&gt;Sys.WebForms.PageRequestManager.getInstance().add_beginRequest&lt;/span&gt;這個事件來做處理。&lt;br /&gt;
&lt;br /&gt;
如果你在$(document).ready中有設定css的class，這個方式在Chrome、Firefox等瀏覽器下，也可以確實的解決問題。但在&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;IE&lt;/span&gt;下，有時你會發現，不管你怎麼重新設定css class，好像都沒作用，javascript事件、function、甚至用$(selector).css()來設定css，全部都有跑，但唯獨設定css class的部份卻跟沒跑一樣。&lt;br /&gt;
&lt;br /&gt;
如果你的css class是寫在網頁中，那這個問題的解決方式有二：&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;1.將你的css屬性，全改用$(selector).css()來設定。&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;2.將你class的style區段移至&amp;lt;head&amp;gt;中&lt;/span&gt;，這樣就可以解決問題了，真是莫明奇妙...&lt;br /&gt;
&lt;br /&gt;
參考資料：&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/256195/jquery-document-ready-and-updatepanels&quot;&gt;http://stackoverflow.com/questions/256195/jquery-document-ready-and-updatepanels&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/1732164/losing-css-class-added-through-jquery-on-updatepanel-partial-postback&quot;&gt;http://stackoverflow.com/questions/1732164/losing-css-class-added-through-jquery-on-updatepanel-partial-postback&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://sudheerkondraguntaprogramming.blogspot.com/2011/05/issue-with-css-stylesheet-and.html&quot;&gt;http://sudheerkondraguntaprogramming.blogspot.com/2011/05/issue-with-css-stylesheet-and.html&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/6112804456984348174/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/07/documentready-updatepanel.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/6112804456984348174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/6112804456984348174'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/07/documentready-updatepanel.html' title='當 $(document).ready 碰上UpdatePanel'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-3703043519619025994</id><published>2011-07-01T07:02:00.000-07:00</published><updated>2011-07-27T05:40:22.043-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><title type='text'>jQuery UI Modal Dialog 中ASP:Button 無法PostBack的解決方式</title><content type='html'>如果有在.NET網頁(aspx)中使用jQuery UI 的Modal Dialog Plugin的人，應該會發現，若將ASP:Button控制項放在Dialog中，裡面的Button按下去是不會PostBack的，google了一下後，發現只要加一行程式就可以解決了，解決方式如下：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;$(&quot;#btnA&quot;).click(function() {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; $(&quot;#divDialog&quot;).dialog({ &amp;nbsp; &amp;nbsp;//顯示Modal Dialog&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; title: &#39;title&#39;,&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; modal: true&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; });&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; //重點在這&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$(&quot;#divDialog&quot;).parent().appendTo($(&quot;form:first&quot;));&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #006000;&quot;&gt;}); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #006000; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;$(&quot;#btnCancel&quot;).click(function() {&lt;/div&gt;&lt;div style=&quot;color: #006000; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp; &amp;nbsp; $(&quot;#divDialog&quot;).dialog(&quot;close&quot;); &amp;nbsp; //關閉Modal Dialog&lt;/div&gt;&lt;div style=&quot;color: #006000; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;});&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
參考資料：&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/568784/jquery-modal-form-dialog-postback-problems&quot;&gt;http://stackoverflow.com/questions/568784/jquery-modal-form-dialog-postback-problems&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/3703043519619025994/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/07/jquery-ui-modal-dialog-aspbutton.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/3703043519619025994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/3703043519619025994'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/07/jquery-ui-modal-dialog-aspbutton.html' title='jQuery UI Modal Dialog 中ASP:Button 無法PostBack的解決方式'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-4704012705084641990</id><published>2011-06-25T19:33:00.000-07:00</published><updated>2011-06-25T19:33:31.353-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Google API"/><title type='text'>Google Map JavaScript API v3 實作滑鼠右鍵(Right Click)選單</title><content type='html'>要實作Google Map的右鍵選單，可參考下列做法，在實作之前，先做好Google Map API的一些基本動作，不熟的人可以參考&lt;a href=&quot;http://jayhsunote.blogspot.com/2011/06/google-map-javascript-api-v3.html&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;之前的文章&lt;/span&gt;&lt;/a&gt;中&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: 13px; font-weight: bold;&quot;&gt;1. Google Map &amp;nbsp;初始化&lt;/span&gt;這段。接著就可以參考下面的動作了。&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
首先可以先設定一個CSS的Class，如下：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;.contextMenu {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;position: absolute;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;min-width: 100px;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;z-index: 1000; &amp;nbsp;/* 必要 */&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;background: #fff;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;border-top: solid 1px #CCC;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;border-left: solid 1px #CCC;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;border-bottom: solid 1px #676767;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;border-right: solid 1px #676767;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;padding: 0px;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;margin: 0px;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;display:none; &amp;nbsp; &amp;nbsp;/* 預設為不顯示 */&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;font-size:smaller;&lt;br /&gt;
}&lt;/div&gt;&lt;/div&gt;其中有個很重要的一點，就是z-index這個屬性一定要給，如果沒給的話，不管你怎麼按右鍵、改程式，選單都不會出來。原因的話，我還沒查到...= = (這是心路歷程)。&lt;br /&gt;
&lt;br /&gt;
再來可以寫一個DIV，就是要在滑鼠右鍵按下( Right Click)時顯示的選單，把class設剛剛寫好的CSS Class：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;div id=&quot;rightMenu&quot; class=&quot;contextMenu&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;a&amp;gt;設為起點&amp;lt;/a&amp;gt; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;a&amp;gt;設為終點&amp;lt;/a&amp;gt; &amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/div&gt;在接下來的JavaScript部份，因為有使用jQuery語法，所以必須要include jQuery，請在&amp;lt;head&amp;gt;中加入這一行程式：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.6.1.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/div&gt;&lt;/div&gt;接下來就是JavaScript部份了：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;script language=&#39;javascript&#39;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; var contextMenu = $(&quot;#rightMenu&quot;); &amp;nbsp; &amp;nbsp;//宣告物件&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $(map.getDiv()).append(contextMenu); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; //加入事件 &lt;br /&gt;
&amp;nbsp; &amp;nbsp; google.maps.event.addListener(map, &quot;rightclick&quot;, function(e) {&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //先隱藏div&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; contextMenu.hide();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var mapDiv = $(map.getDiv());&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var x = e.pixel.x;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var y = e.pixel.y; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //當選單太靠近邊界時，調整選單位置&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (x &amp;gt; mapDiv.width() - contextMenu.width()) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x -= contextMenu.width();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (y &amp;gt; mapDiv.height() - contextMenu.height()) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; y -= contextMenu.height();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;//設定座標，並加入動畫&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; contextMenu.css({ top: y, left: x }).fadeIn(100); &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; });&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //當下列事件觸發時，隱藏選單&lt;br /&gt;
&amp;nbsp; &amp;nbsp; $.each(&#39;click dragstart zoom_changed maptypeid_changed&#39;.split(&#39; &#39;), &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; function(i, name) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; google.maps.event.addListener(map, name, function() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; contextMenu.hide()&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;br /&gt;
&amp;nbsp; &amp;nbsp; });&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;/div&gt;&lt;/div&gt;參考資料：&lt;br /&gt;
&lt;a href=&quot;http://www.pinsoftstudios.com/tips/google-maps-api-v3-right-click-context-menu&quot;&gt;http://www.pinsoftstudios.com/tips/google-maps-api-v3-right-click-context-menu&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/4704012705084641990/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/google-map-javascript-api-v3-right.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/4704012705084641990'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/4704012705084641990'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/google-map-javascript-api-v3-right.html' title='Google Map JavaScript API v3 實作滑鼠右鍵(Right Click)選單'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-5915509637001985285</id><published>2011-06-22T04:53:00.000-07:00</published><updated>2011-06-22T04:54:45.459-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>ASP.NET 動態新增Control、UserControl在PostBack後的處理</title><content type='html'>當有控制項(Control)或使用者控制項(UserControl)在頁面中是屬於動態新增的，若在頁面上不會觸發PostBack事件，其實是很好處理的，在使用上不會有什麼大問題。問題在於觸發PostBack的情況是很容易發生的，當PostBack發生後，你會發現所有動態產生的控制項通通不見了，這個問題實在是很惱人，所以在動態新增控制項時，要做一些特別的處理，程式才會乖乖的照著你的意思跑。&lt;br /&gt;
&lt;br /&gt;
動態增加控制項的方法如下(以下以使用者控制項為例)：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;//載入User Control&lt;br /&gt;
UserControl1 ucObj=(UserControl1)LoadControl(&quot;~/UserControl1.ascx&quot;);&lt;br /&gt;
&lt;br /&gt;
//若為一般控制項(Control)，只要new一個新物件即可&lt;br /&gt;
//以TextBox為例，TextBox txtObj = new TextBox();&lt;br /&gt;
&lt;br /&gt;
panel1.Controls.Add(ucObj); //加在Panel中&lt;/div&gt;&lt;/div&gt;若上述程式放在按鈕的Click事件中，當User每按一次按鈕時，控制項照理說會一直增加，但實際上卻一直只有一個UserControl出現在畫面上。出了什麼問題? 原因就是沒有ViewState，所以PostBack後，原先增加的控制項就消失了，只有最後新增的一個控制項存在。因為是動態新增的，所以在Page_Init時.NET沒辦法將控制項重建，而解決方式就是用ViewState或Session將新增的控制項總數記下來，在Page_Load時將動態新增的控制項加回去，在新增控制項時，要多記錄控制項數目，所以上面的程式要改成如下：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;//載入User Control&lt;br /&gt;
UserControl1 ucObj=(UserControl1)LoadControl(&quot;~/UserControl1.ascx&quot;);&lt;br /&gt;
&lt;br /&gt;
panel1.Controls.Add(ucObj); //加在Panel中&lt;br /&gt;
&lt;br /&gt;
if (ViewState[&quot;UcCount&quot;] != null) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //記錄控制項數目&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ViewState[&quot;UcCount&quot;]= &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(int.Parse(ViewState[&quot;UcCount&quot;].ToString())+1).ToString();&lt;br /&gt;
}else{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ViewState.Add(&quot;UcCount&quot;, &quot;1&quot;);&lt;br /&gt;
}&lt;/div&gt;&lt;/div&gt;另外，在Page_Load事件中，要加入下列程式碼：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;if (ViewState[&quot;UcCount&quot;] != null) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for (int i = 1; i &amp;lt;= int.Parse(ViewState[&quot;UcCount&quot;].ToString()); i++) {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; panel1.Controls.Add((UserControl1)LoadControl(&quot;~/UserControl1.ascx&quot;));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
} &lt;/div&gt;&lt;/div&gt;另外要注意的是，新增控制項時不可以設定ID(ex. ucObj.ID = &quot;xxx&quot;)，否則每次PostBack時，都會視為一個新的物件，而讓PostBack前輸入的值消失。&lt;br /&gt;
&lt;br /&gt;
參考資料：&lt;br /&gt;
http://social.msdn.microsoft.com/forums/zh-TW/236/thread/c18da009-fbcd-437b-9f9c-f758ade1e477/</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/5915509637001985285/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/aspnet-controlusercontrolpostback.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/5915509637001985285'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/5915509637001985285'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/aspnet-controlusercontrolpostback.html' title='ASP.NET 動態新增Control、UserControl在PostBack後的處理'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-2704387677244575423</id><published>2011-06-20T21:57:00.000-07:00</published><updated>2011-06-20T21:58:23.485-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>ASP.NET錯誤：具有潛在危險 Request.Form 的值已從用戶端 偵測到 對應方式</title><content type='html'>在ASP.NET中，預設會將XSS (Cross Site Script)攻擊擋掉，若發現XSS攻擊，ASP.NET就會出現下列這種錯誤訊息：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;具有潛在危險 Request.Form 的值已從用戶端 (XXXX) 偵測到&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;對於網頁開發者來說，自動擋掉錯誤是一件好事，但系統卻會出現錯給你的User看，這是個很不好的，為了避免這種狀況，&lt;br /&gt;
有一種解決方式是將 validateRequest 設成false，如果是針對個別網頁的話，修改的地方如下：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;false&quot; CodeFile=&quot;Test.aspx.cs&quot; Inherits=&quot;Test&quot; validateRequest=&quot;False&quot; %&amp;gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;如果要針對整個網站的話，則是透過修改 web.config來達到整個網站關閉的目的&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;system.web&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;pages validateRequest=&quot;False&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/system.web&amp;gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
但若依上述方式修改，等於是讓系統開了個漏洞，所以若以上述方式修改的話，還必須要為每個控制項的值加入HtmlEncode，以防止XSS攻擊，ex. &lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;txtBox1.Text = HttpUtility.HtmlEncode(txtBox1.Text)&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;總而言之，上面的方式，我個人覺得不太好，所以接下來還有另一種方式：透過Error事件，來做處理。這也有兩種方式可以實作&lt;br /&gt;
第一種方式，是用Page_Error來做處理，在程式中加入如下程式：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; protected void Page_Error(object sender, EventArgs e) { &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (Server.GetLastError().GetType().ToString() == &quot;System.Web.HttpRequestValidationException&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Response.Redirect([要導入的錯誤畫面]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Server.ClearError();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;//清掉錯誤，讓ASP.NET的錯誤不出現&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;若嫌要在每個網頁加上這段程式很麻煩，可以建立一個 BasePage 類別，再讓每個網頁繼承即可。&lt;br /&gt;
&lt;br /&gt;
另外還有一種更方便的方式：在 Global.asax新增application_error事件，程式如下：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp;void Application_Error(Object sender, EventArgs e)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (Server.GetLastError().GetType().ToString() == &quot;System.Web.HttpRequestValidationException&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Response.Redirect([要導入的錯誤畫面]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Server.ClearError();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;這樣就不會出現ASP.NET錯誤了&lt;br /&gt;
&lt;br /&gt;
參考資料：&lt;br /&gt;
&lt;a href=&quot;http://tgw1029.blogspot.com/2010/02/requestform.html&quot;&gt;http://tgw1029.blogspot.com/2010/02/requestform.html&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://social.msdn.microsoft.com/forums/zh-TW/236/thread/a4ecbacc-ffb9-49b9-bf52-93749a3e699a&quot;&gt;http://social.msdn.microsoft.com/forums/zh-TW/236/thread/a4ecbacc-ffb9-49b9-bf52-93749a3e699a&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.dotblogs.com.tw/kirkchen/archive/2009/12/07/12314.aspx&quot;&gt;http://www.dotblogs.com.tw/kirkchen/archive/2009/12/07/12314.aspx&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/2704387677244575423/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/aspnet-requestform.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/2704387677244575423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/2704387677244575423'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/aspnet-requestform.html' title='ASP.NET錯誤：具有潛在危險 Request.Form 的值已從用戶端 偵測到 對應方式'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-2694697265632607133</id><published>2011-06-20T07:48:00.000-07:00</published><updated>2011-06-20T07:53:34.275-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Codeigniter"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><title type='text'>Codeigniter 使用POST方式實作jQuery UI中的AutoComplete(自動完成)</title><content type='html'>要在Codeigniter中利用jQuery來實作AutoComplete，目前比較受歡迎的，大概是這個&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;nbsp;&lt;a href=&quot;http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;jQuery Plugins&lt;/span&gt;&lt;/a&gt; &lt;/span&gt;及&lt;a href=&quot;http://jqueryui.com/demos/autocomplete&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;jQuery UI&lt;/span&gt;&lt;/a&gt;。jQuery Plugins透過POST來實作的方式Google一下就有很多，反而jQuery UI的討論比較少。&lt;br /&gt;
&lt;br /&gt;
在jQuery UI的官方網站中的&lt;a href=&quot;http://jqueryui.com/demos/autocomplete/#multiple-remote&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;範例&lt;/span&gt;&lt;/a&gt;中，是使用 $.getJSON方式來傳輸入的值給Server端，程式如下：&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, Helvetica, Arial, Verdana, sans-serif; font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: #666666; font-size: 1.1em; margin-left: 15px; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code&gt;$.getJSON( &quot;search.php&quot;, {term: extractLast( request.term )}, response );&lt;/code&gt;&lt;/pre&gt;$.getJSON是使用GET方式，與Codeigniter預設是不開放GET有衝突到，所以要解決這個問題有兩種做法：&lt;br /&gt;
一、將Codeigniter中application/config/config.php中的 $config[&#39;enable_query_strings&#39;] 設為 true&lt;br /&gt;
二、不要用 $.getJSON，改用$.ajax來抓server端的資料&lt;br /&gt;
&lt;br /&gt;
下面就來說說第二種改用$.ajax來抓資料的方式。&lt;br /&gt;
&lt;br /&gt;
Server端的程式如下：&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, Helvetica, Arial, Verdana, sans-serif; font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; font-size: 1.1em; margin-left: 15px; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;$aryPara = array(
   $this-&amp;gt;input-&amp;gt;post(&#39;term&#39;)&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #666666; white-space: pre;&quot;&gt; //抓term(使用者所輸入的值)&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;
);

$sql = &quot;SELECT col1 FROM table1 WHERE col1 LIKE CONCAT(?, &#39;%&#39;);&quot;;
$result = $this-&amp;gt;db-&amp;gt;query($sql, $aryPara);&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #666666; white-space: pre;&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #666666; white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;
if($result-&amp;gt;num_rows() &amp;gt; 0){&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #666666; white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #666666; white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;
 &amp;nbsp; $data= array(); //一定要轉成有label及value的array
&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #666666; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt; &amp;nbsp;
 &amp;nbsp; foreach($result-&amp;gt;result() as $row){
      //設定資料, &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;col1替換成你的欄位名稱&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;
 &amp;nbsp; &amp;nbsp; &amp;nbsp;$data[] = array(&#39;label&#39;=&amp;gt; $row-&amp;gt;col1, &#39;value&#39;=&amp;gt; $row-&amp;gt;col1);
 &amp;nbsp; }
}
echo json_encode($data);
&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #666666; white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;
$result-&amp;gt;free_result();
$this-&amp;gt;db-&amp;gt;close();&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #666666; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
Client端的程式如下：&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, Helvetica, Arial, Verdana, sans-serif; font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: #666666; font-size: 1.1em; margin-left: 15px; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code&gt;$(&quot;#txtKeyword&quot;).bind(&quot;keydown&quot;, function( event ) {
    if ( event.keyCode === $.ui.keyCode.TAB &amp;amp;&amp;amp;
           $(this).data(&quot;autocomplete&quot;).menu.active ) {
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;event.preventDefault();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;
    }
})
.autocomplete({
    source: function(request, response) {
       $.ajax({url: &quot;search.php&quot;,
           //注意：這裡是設定post的變數及值，Server端就是以這個變數名稱取值
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;    data: {term: extractLast( request.term )},  
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;    dataType: &quot;json&quot;,
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;    type: &quot;POST&quot;,
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;    success: function(data){
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;            response(data);
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
       });
    },&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;
    search: function() {
      var term = extractLast(this.value);
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;if (term.length &amp;lt; 2 ) { //當字數小於兩個字時，不抓資料
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;          &lt;/span&gt;return false;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;}
    },
    focus: function() {return false;},
    select: function(event, ui) {
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;          &lt;/span&gt;var terms = split( this.value );
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;          &lt;/span&gt;terms.pop();
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;          &lt;/span&gt;terms.push( ui.item.value );
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;          &lt;/span&gt;terms.push( &quot;&quot; );
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;          &lt;/span&gt;this.value = terms.join( &quot;, &quot; );
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;          &lt;/span&gt;return false;
    }
});

function split( val ) {
    return val.split( /,\s*/ );
}
function extractLast(term) {
    return split( term ).pop();
}
&lt;/code&gt;&lt;/pre&gt;這樣就大功告成了。&lt;br /&gt;
&lt;br /&gt;
參考：&lt;br /&gt;
&lt;a href=&quot;http://forum.jquery.com/topic/jquery-autocomplete-new-parameter-implemented-method-get-post&quot;&gt;http://forum.jquery.com/topic/jquery-autocomplete-new-parameter-implemented-method-get-post&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://api.jquery.com/jQuery.getJSON/&quot;&gt;http://api.jquery.com/jQuery.getJSON/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://jqueryui.com/demos/autocomplete/#multiple-remote&quot;&gt;http://jqueryui.com/demos/autocomplete/#multiple-remote&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/2694697265632607133/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/codeigniter-postjquery-uiautocomplete.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/2694697265632607133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/2694697265632607133'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/codeigniter-postjquery-uiautocomplete.html' title='Codeigniter 使用POST方式實作jQuery UI中的AutoComplete(自動完成)'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-3105576143281192718</id><published>2011-06-13T22:46:00.000-07:00</published><updated>2011-06-13T23:10:17.752-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Google API"/><title type='text'>Google Map JavaScript API v3 的一些常用語法</title><content type='html'>下列是使用Google Map API時的一些常用的語法&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;b&gt;1. Google Map &amp;nbsp;初始化：&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
先 include google map api&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;script type=&quot;text/javascript&quot;src=&quot;http://maps.google.com/maps/api/js?sensor=false&quot; &amp;gt;&amp;lt;/script&amp;gt;&lt;/div&gt;&lt;/div&gt;接著在Body中加入下面這個Div，這個Div是要用來顯示Google Map的物件&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;div id=&quot;map_canvas&quot; style=&quot;width:300px;height:300px;&quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/div&gt;接著加入下面的JavaScript程式碼，可以 寫在body的onload事件 或 jQuery的&amp;nbsp;$(document).ready 中&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;var latlng = new google.maps.LatLng(23.69781, 120.96051499999999); &amp;nbsp;//台灣座標&lt;br /&gt;
var myOptions = {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; zoom: 15, &amp;nbsp; &amp;nbsp;//地圖縮放比例，數字越大，路越大&lt;br /&gt;
&amp;nbsp; &amp;nbsp; center: latlng, &amp;nbsp;//地圖的中心座標&lt;br /&gt;
&amp;nbsp; &amp;nbsp; mapTypeId: google.maps.MapTypeId.ROADMAP &amp;nbsp;//地圖型態，可參考 &lt;a href=&quot;http://code.google.com/intl/zh-TW/apis/maps/documentation/javascript/reference.html#MapTypeId&quot;&gt;這裡&lt;/a&gt;&lt;br /&gt;
};&lt;br /&gt;
map = new google.maps.Map(document.getElementById(&quot;map_canvas&quot;), myOptions);&lt;/div&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;b&gt;2. 新增Marker：&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;var myLatlng = new google.maps.LatLng(23.69781, 120.96051499999999);&lt;br /&gt;
var marker = new google.maps.Marker({&lt;br /&gt;
&amp;nbsp; &amp;nbsp; position: myLatlng, &amp;nbsp; &amp;nbsp;//Marker的座標&lt;br /&gt;
&amp;nbsp; &amp;nbsp; map: map, &amp;nbsp; &amp;nbsp;//map物件，以這篇文章的例子，就是上面那個map物件&lt;br /&gt;
&amp;nbsp; &amp;nbsp; title: &#39;title&#39; &amp;nbsp; &amp;nbsp;//當滑鼠移至Marker上時，要顯示的Title文字&lt;br /&gt;
});&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;b&gt;3. 在Marker click時，顯示InfoWindow：&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;google.maps.event.addListener(marker, &#39;click&#39;, function() {&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp; &amp;nbsp; infowindow.open(map, marker);&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;});&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;b&gt;4. 新增InfoWindow：&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;var infowindow = new google.maps.InfoWindow(); &amp;nbsp; &amp;nbsp;//初始一個物件&lt;br /&gt;
infowindow.setContent(&#39;這是內容&#39;); &amp;nbsp; &amp;nbsp;//InfoWindow的內容，可用Html語法&lt;br /&gt;
infowindow.setPosition(myLatlng); &amp;nbsp; &amp;nbsp;//座標&lt;/div&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;b&gt;5. 在地圖Click時新增一個Marker：&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;google.maps.event.addListener(map, &quot;click&quot;, function(event) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; marker_Click = new google.maps.Marker({&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; map: map,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; position: event.latLng&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;/div&gt;&lt;/div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;6. 用地址查座標：&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;function getLatLngByAddr() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; var geocoder = new google.maps.Geocoder(); &amp;nbsp;//定義一個Geocoder物件&lt;br /&gt;
&amp;nbsp; &amp;nbsp; geocoder.geocode(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; { address: &#39;[地址]&#39; }, &amp;nbsp; &amp;nbsp;//設定地址的字串&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; function(results, status) { &amp;nbsp; &amp;nbsp;//callback function&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (status == google.maps.GeocoderStatus.OK) { &amp;nbsp; &amp;nbsp;//判斷狀態&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alert(results[0].geometry.location);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//取得座標 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alert(&#39;Error&#39;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp;);&lt;br /&gt;
}&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
參考：&lt;br /&gt;
&lt;a href=&quot;http://itunes.apple.com/us/app/wikihow-how-to-diy-survival/id309209200?mt=8&quot;&gt;http://itunes.apple.com/us/app/wikihow-how-to-diy-survival/id309209200?mt=8&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://code.google.com/intl/zh-TW/apis/maps/documentation/javascript/reference.html&quot;&gt;Google Map Reference&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://code.google.com/intl/zh-TW/apis/maps/documentation/javascript/tutorial.html&quot;&gt;Google Map API Tutorial&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/3105576143281192718/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/google-map-javascript-api-v3.html#comment-form' title='3 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/3105576143281192718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/3105576143281192718'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/google-map-javascript-api-v3.html' title='Google Map JavaScript API v3 的一些常用語法'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-6940230106576109284</id><published>2011-06-06T19:52:00.000-07:00</published><updated>2011-07-27T05:41:02.726-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Codeigniter"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>Codeigniter上實現Ajax (使用jQuery)</title><content type='html'>下面這個在Codeigniter上實現Ajax的方式，是透過jQuery的post方法來實現，首先寫好一個controller，controller的程式範例如下：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;?php&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;class &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;testAjax&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt; extends CI_Controller {&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #006000; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #006000; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #006000; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;function index()&amp;nbsp;{&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;function &lt;/span&gt;testPost&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;() {&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #006000; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;echo&amp;nbsp;&quot;result=&quot;.&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$this-&amp;gt;input-&amp;gt;post(&#39;para&#39;)&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&amp;nbsp;function &lt;/span&gt;testPara&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$strPara&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;) {&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #006000; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #006000; white-space: pre;&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;echo &quot;result=&quot;.&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$strPara&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #006000; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;?&amp;gt;&lt;/div&gt;&lt;/div&gt;上面有兩個function，分別是以post (testPost)、傳入參數 (testPara)兩種方式來呈現，其實只要選擇一種來實作即可，可以自已選擇自已喜歡的方式。View的程式範例如下：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;html&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;head&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&amp;gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.6.1.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;/head&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;body&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;script language=&#39;javascript&#39;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; //&amp;lt;![CDATA[&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; function &lt;/span&gt;testAjaxPost&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;() {&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&amp;nbsp;   &lt;/span&gt;var options = {&#39;para&#39; : &#39;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[在這輸入para的值]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&#39;};&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;$.post(&#39;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;/index.php/testAjax/testPost&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&#39;, options, function(data) {&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;alert(data);&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;});&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; function &lt;/span&gt;testAjaxPara&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;() { &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #006000; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;color: #006000; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;$.post(&#39;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;/index.php/testAjax/testPara/[在這輸入要傳入$strPara的值]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&#39;, null, function(data) {&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #006000; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;alert(data);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #006000; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;});&lt;/div&gt;&lt;div style=&quot;color: #006000; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; //]]&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/script&amp;gt; &lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;/span&gt;&amp;lt;form id=&#39;frm1&#39; method=&#39;post&#39;&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;table border=&quot;0&quot;&amp;gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;tr&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;td&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;lt;input type=&#39;button&#39; id=&#39;btnTestPost&#39; value=&#39;Post&#39; onclick=&#39;testAjaxPost();&#39; /&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;lt;input type=&#39;button&#39; id=&#39;btnTestPara&#39; value=&#39;Para&#39; onclick=&#39;testAjaxPara();&#39; /&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;/td&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/tr&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/table&amp;gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;/span&gt;&amp;lt;/form&amp;gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;/body&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;這樣就可以執行了，jQuery的post說明如下：&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;div style=&quot;color: #006000;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;$.post(URL [&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;,POST_Para] [,Success] [,Fail]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;URL：Server端的URL。&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;POST_Para：要以Post方式傳入的&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;陣列&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;變數(不需使用時，可不傳入)。&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;Success：&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;成功時要執行的程式碼(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;不需使用時，可不傳入)。&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;Fail：&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;失敗時要執行的程式碼(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;不需使用時，可不傳入)。&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;其中傳入參數(testAjaxPara)方式，可以直接在網址輸入參數的值&lt;br /&gt;
而Post&amp;nbsp;(testAjaxPost)方式則是透過javascript的陣列來傳入參數的值。&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;若要做比較進階的Ajax運用，可以在controller將值輸出成json或xml格式，就可以做到更多的功能&lt;/div&gt;&lt;br /&gt;
參考：&lt;a href=&quot;http://stackoverflow.com/questions/308054/learning-how-to-use-ajax-with-codeigniter&quot;&gt;http://stackoverflow.com/questions/308054/learning-how-to-use-ajax-with-codeigniter&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/6940230106576109284/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/codeigniterajax-jquery.html#comment-form' title='2 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/6940230106576109284'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/6940230106576109284'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/codeigniterajax-jquery.html' title='Codeigniter上實現Ajax (使用jQuery)'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-1409913362882688413</id><published>2011-06-01T02:37:00.000-07:00</published><updated>2011-06-01T17:03:15.755-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Facebook API"/><title type='text'>Facebook login-button的一些研究</title><content type='html'>若想使用Facebook的login-button元件，可參考&lt;a href=&quot;http://developers.facebook.com/docs/&quot;&gt;Facebook Developers Docs&lt;/a&gt;，下列這段就是從範例中節錄下來的，可直接參考使用：&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; color: #006000; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;code style=&quot;color: #006000; font-family: monospace; font-size: 14px;&quot;&gt;&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
      &amp;lt;title&amp;gt;My Facebook Login Page&amp;lt;/title&amp;gt;
    &amp;lt;/head&amp;gt;
    &amp;lt;body&amp;gt;
      &amp;lt;div id=&quot;fb-root&quot;&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;script src=&quot;http://connect.facebook.net/en_US/all.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
      &amp;lt;script&amp;gt;
         FB.init({ 
            appId:&#39;YOUR_APP_ID&#39;, cookie:true, 
            status:true, xfbml:true 
         });
      &amp;lt;/script&amp;gt;
      &amp;lt;fb:login-button&amp;nbsp;&lt;/code&gt;perms=&quot;email,user_checkins&quot;&amp;gt;Login with Facebook&amp;lt;/fb:login-button&amp;gt;
&amp;lt;/body&amp;gt; 
&amp;lt;/html&amp;gt;&lt;/pre&gt;繁體中文語系的人，可以把include的網址改成&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;code style=&quot;color: #006000; font-family: monospace; font-size: 14px;&quot;&gt;http://connect.facebook.net/&lt;/code&gt;&lt;code style=&quot;font-family: monospace; font-size: 14px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;zh_TW&lt;/span&gt;&lt;/code&gt;&lt;code style=&quot;color: #006000; font-family: monospace; font-size: 14px;&quot;&gt;/all.js&lt;/code&gt;&lt;/pre&gt;其中login-button有下列&amp;nbsp;&lt;a href=&quot;http://developers.facebook.com/docs/reference/plugins/login/&quot;&gt;官方公佈的屬性&lt;/a&gt;&amp;nbsp;可以使用：&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;font-family: &#39;Lucida Grande&#39;, Tahoma, Verdana, Arial, sans-serif; font-size: 14px; list-style-type: disc; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 3em; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;li style=&quot;color: #333333; font-size: 14px; line-height: 18px;&quot;&gt;&lt;code style=&quot;color: #006000; font-family: monospace; font-size: 14px;&quot;&gt;show-faces&lt;/code&gt;&amp;nbsp;- 是否顯示Facebook的圖像(照片)&lt;/li&gt;
&lt;li style=&quot;font-size: 14px; line-height: 18px;&quot;&gt;&lt;code style=&quot;color: #006000; font-family: monospace; font-size: 14px;&quot;&gt;width&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;&amp;nbsp;- 設定元件的寬度 &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;(注意！不是按鈕的寬度)&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;，預設為200&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;color: #333333; font-size: 14px; line-height: 18px;&quot;&gt;&lt;code style=&quot;color: #006000; font-family: monospace; font-size: 14px;&quot;&gt;max-rows&lt;/code&gt;&amp;nbsp;- 設定圖像(照片)顯示最大的列數，預設為1 (不知道可以做什麼用? 試了沒效果)&lt;/li&gt;
&lt;li style=&quot;color: #333333; font-size: 14px; line-height: 18px;&quot;&gt;&lt;code style=&quot;color: #006000; font-family: monospace; font-size: 14px;&quot;&gt;perms&amp;nbsp;&lt;/code&gt;- 要求Facebook使用者授權的項目，詳細屬性可至 &lt;a href=&quot;http://developers.facebook.com/docs/authentication/permissions/&quot;&gt;這裡&lt;/a&gt;&amp;nbsp;查看&lt;/li&gt;
&lt;/ul&gt;除了上面這些屬性，其實還有一些屬性是可以用的：&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;font-family: &#39;Lucida Grande&#39;, Tahoma, Verdana, Arial, sans-serif; font-size: 14px; list-style-type: disc; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 3em; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;li style=&quot;color: #333333; font-size: 14px; line-height: 18px;&quot;&gt;&lt;code style=&quot;color: #006000; font-family: monospace; font-size: 14px;&quot;&gt;autologoutlink&lt;/code&gt; - &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;是否顯示 登出 按鈕，true: 若使用者登入，會顯示登出；false: 若使用者登入，還是顯示登入。&lt;/span&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li style=&quot;font-size: 14px; line-height: 18px;&quot;&gt;&lt;code style=&quot;color: #006000; font-family: monospace; font-size: 14px;&quot;&gt;size&lt;/code&gt; - &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;按鈕大小，可使用：small、medium、large、xlarge。&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;font-size: 14px; line-height: 18px;&quot;&gt;&lt;code style=&quot;color: #006000; font-family: monospace; font-size: 14px;&quot;&gt;length&lt;/code&gt; - &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;按鈕內預設文字的長度，ex. short:登入、long:用Facebook登入。若是自訂文字的話，這個屬性是沒作用的。&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;font-size: 14px; line-height: 18px;&quot;&gt;&lt;code style=&quot;color: #006000; font-family: monospace; font-size: 14px;&quot;&gt;background&lt;/code&gt; - &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;指定按鈕的背景色，可使用white、light、dark。預設為light&lt;/span&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;如果要更改按鈕上的字，可以照下面這樣改，這樣就可以修改按鈕中的文字了。  &lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; font-family: monospace; font-size: 14px; line-height: 18px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&lt;code style=&quot;color: #006000; font-family: monospace; font-size: 14px;&quot;&gt;&amp;lt;fb:login-button&lt;/code&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[在這輸入文字]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&amp;lt;/fb:login-button&amp;gt;&lt;/span&gt;&lt;/pre&gt;但若有將上面的autologoutlink設為true，且login-button該變為「登出」時，login-button中的文字卻會一樣是自已輸入的登入文字，這點還蠻奇怪的，我還沒找到方法解決這個問題。&lt;br /&gt;
&lt;br /&gt;
若要在login-button登入後執行一些動作，可以在FB.init後加上：&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 14px; line-height: 18px;&quot;&gt;FB.Event.subscribe(&#39;auth.login&#39;, function(response) {
            //打上你的程式碼
          });&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
這樣就可以在login之後做您想做的事，同理，若要在登出後做某些事，只要把 auth.login 改成 auth.logout 即可&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;--------------------------------- 接下來要說自訂按鈕的用法 ---------------------------------------- &lt;br /&gt;
&lt;br /&gt;
上面的用法，是直接使用Facebook內定的按鈕，只要放上FBML Tag即可使用。但若如果要自訂登入按鈕的話，可以直接寫一個function，如：  &lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 14px; line-height: 18px;&quot;&gt;function fbLogin() {  
      FB.login(function(response) {
       if (response.session) {
         if (response.perms) {
          //使用者已登入Facebook成功，且已授權你的應用程式存取
         } else {
           //使用者已登入Facebook成功，但未授權你的應用程式存取
         }
       } else {
         //使用者未登入成功
       }
     }, {perms:&#39;publish_stream,offline_access&#39;}); //設定需要授權的項目
  }&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;接著再放入一個Html Tag，如button，在onclick中呼叫function即可：  &lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f2f2f2; background-image: initial; background-origin: initial; border-bottom-color: rgb(216, 223, 234); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(216, 223, 234); border-left-style: solid; border-left-width: 3px; border-right-color: rgb(216, 223, 234); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(216, 223, 234); border-top-style: solid; border-top-width: 1px; margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px; overflow-x: auto; overflow-y: auto; padding-bottom: 7px; padding-left: 10px; padding-top: 7px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #006000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 14px; line-height: 18px;&quot;&gt;&amp;lt;input type=&#39;button&#39; value=&#39;登入&#39; onclick=&quot;fbLogin();&quot;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;要注意的是，若你放的是input tag，千萬要切記啊，&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red; font-size: large;&quot;&gt;type不可以使用submit&lt;/span&gt;，否則當你按下按鈕，跳出Facebook登入視窗，並輸入帳號密碼登入後，你只會看到一個白色的畫面，標題上面寫著「XD Proxy」，然後你的function連動都不會動，但卻已成功登入進Facebook。&lt;br /&gt;
&lt;br /&gt;
PS.今天卡了一個下午就是在查這個問題，google查的都沒有效 (facebook login-button popup blank)，就在要放棄時，想說該不會是submit的問題，結果就好了，我也不知道是什麼原因造成這結果.....&lt;br /&gt;
&lt;br /&gt;
參考：&lt;br /&gt;
&lt;a href=&quot;http://developers.facebook.com/docs/&quot;&gt;http://developers.facebook.com/docs/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://forum.developers.facebook.net/viewtopic.php?id=72137&quot;&gt;http://forum.developers.facebook.net/viewtopic.php?id=72137&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/1409913362882688413/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/facebook-login-button.html#comment-form' title='2 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/1409913362882688413'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/1409913362882688413'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/06/facebook-login-button.html' title='Facebook login-button的一些研究'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-7159700885453404911</id><published>2011-05-26T02:02:00.000-07:00</published><updated>2011-05-26T02:03:23.341-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="程式通用"/><title type='text'>Subversion(SVN)與CVS的比較</title><content type='html'>最近在比較CVS與SVN的差異，下列表格是整理出來的重點，參考看看：&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse; width: 100%;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;mso-width-alt: 6560; mso-width-source: userset; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;col style=&quot;mso-width-alt: 8256; mso-width-source: userset; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;col style=&quot;mso-width-alt: 9504; mso-width-source: userset; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;/colgroup&gt;&lt;tbody&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl63&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #2da2bf; border-bottom: white 1.5pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white 1pt solid; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;項目&lt;/span&gt;&lt;span class=&quot;font5&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td class=&quot;xl64&quot; dir=&quot;ltr&quot; style=&quot;background-color: #2da2bf; border-bottom: white 1.5pt solid; border-left: white; border-right: white 1pt solid; border-top: white 1pt solid; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;CVS&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td class=&quot;xl64&quot; dir=&quot;ltr&quot; style=&quot;background-color: #2da2bf; border-bottom: white 1.5pt solid; border-left: white; border-right: white 1pt solid; border-top: white 1pt solid; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;SVN&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;29&quot; style=&quot;height: 21.75pt;&quot;&gt;&lt;td class=&quot;xl65&quot; dir=&quot;ltr&quot; height=&quot;29&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21.75pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;資料夾的版本控制&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl66&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;NG&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl66&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;OK&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;檔案重新命名&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl68&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;NG&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl68&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;OK&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;檔案移動&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl70&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;NG&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl70&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;OK&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;檔案複製&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl68&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;NG&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl68&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;OK&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;資料夾的刪除&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl70&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;NG&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl70&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;OK&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;新舊資料夾的比較&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl68&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;NG&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl68&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;OK&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;中文檔名的支援&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl70&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;Big5&lt;/span&gt;&lt;span class=&quot;font6&quot; style=&quot;font-family: Arial;&quot;&gt;、&lt;/span&gt;&lt;span class=&quot;font7&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;UTF-8&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl70&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;UTF-8&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;檔案儲存&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;以實體檔案儲存&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;以資料庫儲存&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;耗費&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;Server&lt;/span&gt;&lt;span class=&quot;font6&quot; style=&quot;font-family: Arial;&quot;&gt;空間大小&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;大&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;小&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;55&quot; style=&quot;height: 41.25pt;&quot;&gt;&lt;td class=&quot;xl68&quot; dir=&quot;ltr&quot; height=&quot;55&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 41.25pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;Commit&lt;/span&gt;&lt;span class=&quot;font6&quot; style=&quot;font-family: Arial;&quot;&gt;時，上傳的內容&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span class=&quot;font9&quot; style=&quot;font-family: 細明體;&quot;&gt;上傳整個檔案&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;只上傳差異部份&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;檔案類型區分&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;文字、&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;binary&lt;/span&gt;&lt;span class=&quot;font6&quot; style=&quot;font-family: Arial;&quot;&gt;、&lt;/span&gt;&lt;span class=&quot;font7&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;unicode&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;全視為&lt;/span&gt;&lt;span class=&quot;font7&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;Binary&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;55&quot; style=&quot;height: 41.25pt;&quot;&gt;&lt;td class=&quot;xl68&quot; dir=&quot;ltr&quot; height=&quot;55&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 41.25pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;Commit&lt;/span&gt;&lt;span class=&quot;font6&quot; style=&quot;font-family: Arial;&quot;&gt;時的檔案類型&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;要自已指定檔案類型&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;不需指定&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl70&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;Commit&lt;/span&gt;&lt;span class=&quot;font6&quot; style=&quot;font-family: Arial;&quot;&gt;的一致性&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;無&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;Rollback&lt;/span&gt;&lt;span class=&quot;font6&quot; style=&quot;font-family: Arial;&quot;&gt;功能&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;有&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;Rollback&lt;/span&gt;&lt;span class=&quot;font6&quot; style=&quot;font-family: Arial;&quot;&gt;功能&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;檔案差異比較&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;只有文字可比較&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;全部檔案都可比較&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;衝突處理&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;僅告知衝突&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl69&quot; dir=&quot;ltr&quot; style=&quot;background-color: #cde0e8; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;必須解除衝突才可&lt;/span&gt;&lt;span class=&quot;font7&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;Commit&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr height=&quot;28&quot; style=&quot;height: 21pt;&quot;&gt;&lt;td class=&quot;xl68&quot; dir=&quot;ltr&quot; height=&quot;28&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white 1pt solid; border-right: white 1pt solid; border-top: white; height: 21pt; width: 154pt;&quot; width=&quot;205&quot;&gt;&lt;span style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;Branch&lt;/span&gt;&lt;span class=&quot;font6&quot; style=&quot;font-family: Arial;&quot;&gt;、&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;Tag&lt;/span&gt;&lt;span class=&quot;font6&quot; style=&quot;font-family: Arial;&quot;&gt;的管理&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 194pt;&quot; width=&quot;258&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;可用版本號碼控管&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;xl67&quot; dir=&quot;ltr&quot; style=&quot;background-color: #e8f0f4; border-bottom: white 1pt solid; border-left: white; border-right: white 1pt solid; border-top: white; width: 223pt;&quot; width=&quot;297&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;必須手動用目錄來控管&lt;/span&gt;&lt;span class=&quot;font7&quot; style=&quot;font-family: Lucida Sans Unicode;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;br /&gt;
參考：&lt;br /&gt;
SVN中文手冊&lt;br /&gt;
&lt;a href=&quot;http://twpug.net/docs/Subversion/&quot;&gt;http://twpug.net/docs/Subversion/&lt;/a&gt;&lt;br /&gt;
SVN官方網站&lt;br /&gt;
&lt;a href=&quot;http://subversion.tigris.org/&quot;&gt;http://subversion.tigris.org/&lt;/a&gt;&lt;br /&gt;
選擇SVN的理由&lt;br /&gt;
&lt;a href=&quot;http://blog.xuite.net/jackytseng7028/WikiLife/26020467&quot;&gt;http://blog.xuite.net/jackytseng7028/WikiLife/26020467&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/7159700885453404911/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/05/subversionsvncvs.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/7159700885453404911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/7159700885453404911'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/05/subversionsvncvs.html' title='Subversion(SVN)與CVS的比較'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-5543782716050486545</id><published>2011-05-22T06:43:00.000-07:00</published><updated>2011-05-22T06:47:13.031-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="XSL"/><category scheme="http://www.blogger.com/atom/ns#" term="程式通用"/><title type='text'>XSL中轉換產出格式的方法</title><content type='html'>使用XSL來轉XML時，若要在XSL中轉換產出值的格式，有下列幾種方式：&lt;br /&gt;
一、可使用一些&lt;a href=&quot;http://www.w3schools.com/xsl/xsl_functions.asp&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #8e7cc3;&quot;&gt;內建的函式&lt;/span&gt;&lt;/a&gt;來做轉換 (但內建的函式實在是很少...)：&lt;br /&gt;
&lt;div style=&quot;border: 1px solid #000000; padding: 3px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&amp;lt;x:value-of select=&quot;format-number(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[節點名稱]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;, &#39;###,###&#39;)&quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt;則會將數字的資料轉為如 123,456 這種格式&lt;br /&gt;
&lt;br /&gt;
二、自已寫XSL的function來做轉換&lt;br /&gt;
&lt;br /&gt;
三、寫Script來做轉換，這個方式可以做到的功能就很多了，看是要用JavaScript、C#、VB...都可以，下列的例子是用來做日期轉換的函式：&lt;br /&gt;
&lt;div style=&quot;border: 1px solid #000000; padding: 3px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&amp;lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&amp;nbsp; &amp;nbsp; xmlns:msxsl=&quot;urn:schemas-microsoft-com:xslt&quot; exclude-result-prefixes=&quot;msxsl&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[前置詞]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&quot; extension-element-prefixes=&quot;msxsl&quot; xmlns:&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[前置詞]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;=&quot;urn:&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[前置詞]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&quot;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
若是用Visual Studio 2008產生的XSL檔案的話，要在上面這段加入下面兩段文字&lt;br /&gt;
&lt;div style=&quot;border: 1px solid #000000; padding: 3px;&quot;&gt;1. &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;xmlns:&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[前置詞]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;=&quot;urn:&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[前置詞]&lt;/span&gt;&quot;&lt;br /&gt;
2. &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;exclude-result-prefixes=&quot;msxsl&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[前置詞]&lt;/span&gt;&quot;&lt;/div&gt;&lt;br /&gt;
[前置詞] 是由自已隨便輸入的，但在使用時要注意全部都要相同。接下來再加入下列程式碼(範例)：&lt;br /&gt;
&lt;div style=&quot;border: 1px solid #000000; padding: 3px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&amp;lt;msxsl:script implements-prefix=&quot;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[前置詞 ]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&quot; language=&quot;C#&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;![CDATA[&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; public string FormatDateTime(string xsdDateTime, string format)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DateTime date = DateTime.Parse(xsdDateTime);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return date.ToString(format);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&amp;nbsp; &amp;nbsp; ]]&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&amp;lt;/msxsl:script&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
最後在使用時，直接像下面程式般呼叫函式，即可做到相當多的功能。&lt;br /&gt;
&lt;div style=&quot;border: 1px solid #000000; padding: 3px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;&amp;lt;xsl:value-of select=&quot;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[前置詞 ]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;:FormatDateTime(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[節點名稱]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;, &#39;yyyy MM DD&#39;)&quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
參考：&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/500915/format-a-date-in-xml-via-xslt&quot;&gt;http://stackoverflow.com/questions/500915/format-a-date-in-xml-via-xslt&lt;/a&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Calibri, sans-serif; font-size: 12pt;&quot;&gt;&lt;a href=&quot;http://stackoverflow.com/questions/669291/xslt-decimal-formatting-based-on-input-xml&quot;&gt;http://stackoverflow.com/questions/669291/xslt-decimal-formatting-based-on-input-xml&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.w3schools.com/xsl/&quot;&gt;http://www.w3schools.com/xsl/&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/5543782716050486545/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/05/xsl.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/5543782716050486545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/5543782716050486545'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/05/xsl.html' title='XSL中轉換產出格式的方法'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-3901715754754527637</id><published>2011-05-19T23:53:00.000-07:00</published><updated>2011-05-21T05:14:16.523-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="程式通用"/><title type='text'>規則運算式(正規表示式)語法整理</title><content type='html'>以下為參考 &lt;a href=&quot;http://zh.wikipedia.org/zh-tw/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F&quot;&gt;Wiki &lt;/a&gt;後，修改成自已比較能了解的規則運算式符號整理：&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;以下資料仍有一些不太了解或不知道該如何解釋的地方，請見諒。&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; style=&quot;color: #222222; font-family: &amp;quot;Courier New&amp;quot;, Courier, FreeMono, monospace; line-height: 18px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;編號&lt;/td&gt;&lt;td&gt;字元&lt;/td&gt;&lt;td&gt;描述&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;&lt;b&gt;\&lt;/b&gt;&lt;/td&gt;&lt;td&gt;特殊字元的前置符號，將下一個字元標記為一個特殊字元。例如，「\n」代表換行符號。「\\」代表「\」而「\(」則代表「(」。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;b&gt;^&lt;/b&gt;&lt;/td&gt;&lt;td&gt;表示字串必須以後面的字元開頭。ex. ^aa，表示必須以aa開頭。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;&lt;b&gt;$&lt;/b&gt;&lt;/td&gt;&lt;td&gt;表示字串必須以後面的字元結尾。ex. aa$，表示必須以aa結尾。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;&lt;b&gt;*&lt;/b&gt;&lt;/td&gt;&lt;td&gt;表示 * 前面的字元可出現或不出現。例如：Gooo*gle 能匹配 Google、Goooooogle。* 等於 {0,}。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;&lt;b&gt;+&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: black; font-family: &#39;Times New Roman&#39;; line-height: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; color: #222222; font-family: &#39;Courier New&#39;, Courier, FreeMono, monospace; line-height: 18px;&quot;&gt;表示&lt;/span&gt;&amp;nbsp;+ 前面的字元至少要出現一次(可出現多次)，ex.go+gle 表示這個字串可以為gogle、google、gooooogle...。&lt;/span&gt;+ 等於 {1,}&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;&lt;b&gt;?&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: black; font-family: &#39;Times New Roman&#39;; line-height: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; color: #222222; font-family: &#39;Courier New&#39;, Courier, FreeMono, monospace; line-height: 18px;&quot;&gt;表示&lt;/span&gt;&amp;nbsp;? 前面的字元最多只可以出現一次(可不出現)。ex.colou?r 表示這個字串可以為color或colour。&lt;/span&gt;? 等於 {0,1}&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;&lt;b&gt;{n}&lt;/b&gt;&lt;/td&gt;&lt;td&gt;大括號「{}」中包起來的數字n是一個非負整數。代表前面的字元一定要出現n次。例如：o{3} 可以為 Gooogle 的 ooo，但不能匹配 Google。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;&lt;b&gt;{n,}&lt;/b&gt;&lt;/td&gt;&lt;td&gt;大括號「{}」中包起來的數字n是一個非負整數。代表前面的字元至少要出現n次。ex.go{2,}gle 可以為google、goooogle，但gogle就不合格。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;&lt;b&gt;{n,m}&lt;/b&gt;&lt;/td&gt;&lt;td&gt;大括號「{}」中包起來的數字n是一個非負整數。代表前面的字元至少要出現n次，最多不可超過m次。n要小於等於m。ex. go{2,4}gle可以為google、goooogle，但gogle、gooooogle就不合格。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;10&lt;/td&gt;&lt;td&gt;&lt;b&gt;?&lt;/b&gt;&lt;/td&gt;&lt;td&gt;當?字元放在次數限制符號（*,+,?，{n}，{n,}，{n,m}）後時，表示要不貪心的尋找，可增加效能。不貪心表示只要找到一個就好，不再找別的。&lt;br /&gt;
參考：&lt;a href=&quot;http://deer.nublog.cc/article.php?i=20080225&quot;&gt;http://deer.nublog.cc/article.php?i=20080225&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;11&lt;/td&gt;&lt;td&gt;&lt;b&gt;.&lt;/b&gt;&lt;/td&gt;&lt;td&gt;表示除「\n」之外的任何字元。要表示包括「\n」在內的任何字元，請使用「[.\n]」。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;12&lt;/td&gt;&lt;td&gt;&lt;b&gt;(pattern)&lt;/b&gt;&lt;/td&gt;&lt;td&gt;小括號代表中間的pattern為一群組。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;13&lt;/td&gt;&lt;td&gt;&lt;b&gt;(?:pattern)&lt;/b&gt;&lt;/td&gt;&lt;td&gt;匹配pattern但不獲取匹配結果，也就是說這是一個非獲取匹配，不進行儲存供以後使用。例如：run(?:n|ning) 能匹配 running 整個字串，並且從此字串後繼續比對。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;13&lt;/td&gt;&lt;td&gt;&lt;b&gt;(?=pattern)&lt;/b&gt;&lt;/td&gt;&lt;td&gt;正向預查，在任何匹配pattern的字串開始處匹配尋找字串。這是一個非獲取匹配，也就是說，該匹配不需要獲取供以後使用。例如：Office(?=2003|2007|2010) 能匹配 Office2003 中的 Office，但不能匹配 Office2005 中的 Office，而從 Office 字串後繼續比對。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;14&lt;/td&gt;&lt;td&gt;&lt;b&gt;(?!pattern)&lt;/b&gt;&lt;/td&gt;&lt;td&gt;負向預查，在任何不匹配pattern的字串開始處匹配尋找字串。這是一個非獲取匹配，也就是說，該匹配不需要獲取供以後使用。例如：Office(?!2003|2007|2010) 能匹配 Office2005 中的 Office，但不能匹配 Office2010 中的 Office，而從 Office 字串後繼續比對。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;15&lt;/td&gt;&lt;td&gt;&lt;b&gt;x|y&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: black; font-family: &#39;Times New Roman&#39;; line-height: normal;&quot;&gt;代表OR，ex. (A|a)pple 表示 這個字串可以為Apple或apple&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;16&lt;/td&gt;&lt;td&gt;&lt;b&gt;[xyz]&lt;/b&gt;&lt;/td&gt;&lt;td&gt;代表可為中括號[]內的任一字元。ex.[abc]表示可為a、b、c任一字元。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;17&lt;/td&gt;&lt;td&gt;&lt;b&gt;[^xyz]&lt;/b&gt;&lt;/td&gt;&lt;td&gt;代表不可為中括號[]內的任一字元。ex.[abc]表示不可為a、b、c任一字元。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;18&lt;/td&gt;&lt;td&gt;&lt;b&gt;[a-z]&lt;/b&gt;&lt;/td&gt;&lt;td&gt;代表可為中括號[]內的字元區間內的任一字元。ex.[a-z]表示可為a~z間的任一字元。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;19&lt;/td&gt;&lt;td&gt;&lt;b&gt;[^a-z]&lt;/b&gt;&lt;/td&gt;&lt;td&gt;代表不可為中括號[]內的字元區間內的任一字元。ex.[a-z]表示不可為a~z間的任一字元。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;20&lt;/td&gt;&lt;td&gt;&lt;b&gt;\b&lt;/b&gt;&lt;/td&gt;&lt;td&gt;表示字和空白之間的交會點。ex.於aa bb aabb時，可以用 aa\b 找出 aa，而不會找出aabb、也不會找出「aa (空格)」。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;21&lt;/td&gt;&lt;td&gt;&lt;b&gt;\B&lt;/b&gt;&lt;/td&gt;&lt;td&gt;表示非字和空白之間的交會點&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;22&lt;/td&gt;&lt;td&gt;&lt;b&gt;\cx&lt;/b&gt;&lt;/td&gt;&lt;td&gt;表示一個控制字元。例如，\cM匹配一個Control-M或Enter符。x的值必須為A-Z或a-z之一。否則會將c視為一個單純的「c」字元。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;23&lt;/td&gt;&lt;td&gt;&lt;b&gt;\d&lt;/b&gt;&lt;/td&gt;&lt;td&gt;可為任何數字。\d 等於[0-9]。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;24&lt;/td&gt;&lt;td&gt;&lt;b&gt;\D&lt;/b&gt;&lt;/td&gt;&lt;td&gt;不可為數字。\D 等於[^0-9]。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;25&lt;/td&gt;&lt;td&gt;&lt;b&gt;\f&lt;/b&gt;&lt;/td&gt;&lt;td&gt;換頁符號。\f 等於\x0c和\cL。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;26&lt;/td&gt;&lt;td&gt;&lt;b&gt;\n&lt;/b&gt;&lt;/td&gt;&lt;td&gt;換行符號。\n 等於\x0a和\cJ。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;27&lt;/td&gt;&lt;td&gt;&lt;b&gt;\r&lt;/b&gt;&lt;/td&gt;&lt;td&gt;Enter符號。\r 等於\x0d和\cM。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;28&lt;/td&gt;&lt;td&gt;&lt;b&gt;\s&lt;/b&gt;&lt;/td&gt;&lt;td&gt;代表任何空白字元，包括空格、製表符、換頁符等等。\s 等於[\f\n\r\t\v]。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;29&lt;/td&gt;&lt;td&gt;&lt;b&gt;\S&lt;/b&gt;&lt;/td&gt;&lt;td&gt;代表任何非空白字元。\S 等於[^\f\n\r\t\v]。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;30&lt;/td&gt;&lt;td&gt;&lt;b&gt;\t&lt;/b&gt;&lt;/td&gt;&lt;td&gt;代表Tab字元。\t 等於\x09和\cI。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;31&lt;/td&gt;&lt;td&gt;&lt;b&gt;\v&lt;/b&gt;&lt;/td&gt;&lt;td&gt;代表垂直Tab字元(Vertical Tab)。\v 等於\x0b和\cK。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;32&lt;/td&gt;&lt;td&gt;&lt;b&gt;\w&lt;/b&gt;&lt;/td&gt;&lt;td&gt;可為包括底線「_」的任何文字、數字。\w 等於「[A-Za-z0-9_]」。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;33&lt;/td&gt;&lt;td&gt;&lt;b&gt;\W&lt;/b&gt;&lt;/td&gt;&lt;td&gt;不可為包括底線「_」的任何文字、數字。。\W 等於「[^A-Za-z0-9_]」。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;34&lt;/td&gt;&lt;td&gt;&lt;b&gt;\xn&lt;/b&gt;&lt;/td&gt;&lt;td&gt;表示為n所代表的ASCII字元，n為十六進位值。十六進位值僅可寫兩個字元。例如，「\x41」匹配「A」。「\x041」則等價於「\x04&amp;amp;1」。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;35&lt;/td&gt;&lt;td&gt;&lt;b&gt;\num&lt;/b&gt;&lt;/td&gt;&lt;td&gt;num是一個正整數。對前方括號內的字元做重複的動作。例如，「(.)\1」代表兩個連續的相同字元。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;36&lt;/td&gt;&lt;td&gt;&lt;b&gt;\n&lt;/b&gt;&lt;/td&gt;&lt;td&gt;標識一個八進制轉義值或一個向後參照。如果\n之前至少n個獲取的子運算式，則n為向後參照。否則，如果n為八進制數位（0-7），則n為一個八進制轉義值。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;37&lt;/td&gt;&lt;td&gt;&lt;b&gt;\nm&lt;/b&gt;&lt;/td&gt;&lt;td&gt;標識一個八進制轉義值或一個向後參照。如果\nm之前至少有nm個獲得子運算式，則nm為向後參照。如果\nm之前至少有n個獲取，則n為一個後跟文字m的向後參照。如果前面的條件都不滿足，若n和m均為八進制數位（0-7），則\nm將匹配八進制轉義值nm。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;38&lt;/td&gt;&lt;td&gt;&lt;b&gt;\nml&lt;/b&gt;&lt;/td&gt;&lt;td&gt;如果n為八進位數字（0-3），且m和l均為八進位數字（0-7），則代表八進位數字所代表的值。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;39&lt;/td&gt;&lt;td&gt;&lt;b&gt;\un&lt;/b&gt;&lt;/td&gt;&lt;td&gt;n是一個用四個十六進位數字表示的Unicode字元。代表n所表達的字元。例如，\u00A9代表版權符號（©）。&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;40&lt;/td&gt;&lt;td&gt;&lt;b&gt;\on&lt;/b&gt;&lt;/td&gt;&lt;td&gt;n是一個用二個八進位數字表示的Unicode字元。代表n所表達的字元。例如，\o47。&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;參考資料：&lt;br /&gt;
&lt;a href=&quot;http://deer.nublog.cc/article.php?i=20080225&quot;&gt;http://deer.nublog.cc/article.php?i=20080225&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://ericbbs.blogspot.com/2009/08/2.html&quot;&gt;http://ericbbs.blogspot.com/2009/08/2.html&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/3901715754754527637/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/05/blog-post.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/3901715754754527637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/3901715754754527637'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/05/blog-post.html' title='規則運算式(正規表示式)語法整理'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-1824557993790909720</id><published>2011-05-14T21:17:00.000-07:00</published><updated>2011-06-09T21:09:03.173-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>PHP fopen、file_get_contents使用注意事項</title><content type='html'>當使用PHP中的fopen、file_get_contents..等函數等，Server端一定要可以連到該URL的網頁，語法如下：&lt;br /&gt;
&lt;div style=&quot;border-style: solid; border-width: 1px; padding: 5px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7f6000;&quot;&gt;file_get_contents(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;[URL]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7f6000;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
若出現下列錯誤訊息：&lt;br /&gt;
&lt;div style=&quot;border-style: solid; border-width: 1px; padding: 5px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7f6000; font-family: inherit;&quot;&gt;Message: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
表示Server的IP變更過，而Apache沒有重新啟動過，這時只要將 Apache重新啟動即可解決這個錯誤。</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/1824557993790909720/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/05/php-fopenfilegetcontents.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/1824557993790909720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/1824557993790909720'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/05/php-fopenfilegetcontents.html' title='PHP fopen、file_get_contents使用注意事項'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4798799528175341639.post-212914301342496384</id><published>2011-05-14T07:44:00.000-07:00</published><updated>2011-05-14T07:46:44.821-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><title type='text'>CentOS 5.5中PHP升級至 5.3的方法</title><content type='html'>因為json_decode這個function 只在php 5.2以後支援，而CentOS 5.5 中的php卻只有5.1，官方的yum更新也還沒推出，所以在php升級這一塊，就得另外想辦法。&lt;br /&gt;
&lt;br /&gt;
在參考google大神的意見之後，升級至5.3版最簡單的方法大概是這個吧：&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-color: #fafafa; border-bottom-color: rgb(187, 187, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(187, 187, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(187, 187, 187); border-top-style: solid; border-top-width: 1px; line-height: 15px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 1em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.99em; padding-left: 0.99em; padding-right: 0.99em; padding-top: 0.99em; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7f6000; font-size: x-small;&quot;&gt;wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh epel-release-5*.rpm
rpm -Uvh remi-release-5*.rpm&amp;nbsp;
yum -y --enablerepo=remi update php-\*&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
若你的MySQL沒有升級，還是5.0版的話，上列命令執行後，會出現衝突的錯誤，錯誤訊息如下：&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-color: #fafafa; border-bottom-color: rgb(187, 187, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(187, 187, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(187, 187, 187); border-top-style: solid; border-top-width: 1px; line-height: 15px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 1em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.99em; padding-left: 0.99em; padding-right: 0.99em; padding-top: 0.99em; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7f6000;&quot;&gt;Transaction Check Error:
&amp;nbsp; file /etc/my.cnf from install of mysql-libs-5.5.12-1.el5.remi.i386 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
&amp;nbsp; file /usr/share/mysql/charsets/Index.xml from install of mysql-libs-5.5.12-1.el5.remi.i386 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
&amp;nbsp; file /usr/share/mysql/charsets/cp1250.xml from install of mysql-libs-5.5.12-1.el5.remi.i386 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
看到上面這個錯誤訊息，其實也不用將mysql移除再重裝，直接執行下面的命令去更新mysql到最新版本即可，而且會連php、php-mysql都更新成5.3.6。&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-color: #fafafa; border-bottom-color: rgb(187, 187, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(187, 187, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(187, 187, 187); border-top-style: solid; border-top-width: 1px; line-height: 15px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 1em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.99em; padding-left: 0.99em; padding-right: 0.99em; padding-top: 0.99em; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 5px; -webkit-border-vertical-spacing: 5px; color: #7f6000; font-family: Monaco, &#39;Courier New&#39;, monospace; font-size: 12px; line-height: 18px;&quot;&gt;yum -y --enablerepo=remi update mysql-\*&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 5px; -webkit-border-vertical-spacing: 5px; color: #006600; font-family: Monaco, &#39;Courier New&#39;, monospace; font-size: 12px; line-height: 18px;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
參考資料：&lt;br /&gt;
&lt;a href=&quot;http://forum.icst.org.tw/phpbb/viewtopic.php?f=16&amp;amp;t=19416&quot;&gt;http://forum.icst.org.tw/phpbb/viewtopic.php?f=16&amp;amp;t=19416&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://blog.wu-boy.com/2009/09/rhelinstalling-php-52x-or-53x-on-redhat-es5-centos-5/&quot;&gt;http://blog.wu-boy.com/2009/09/rhelinstalling-php-52x-or-53x-on-redhat-es5-centos-5/&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jayhsunote.blogspot.com/feeds/212914301342496384/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://jayhsunote.blogspot.com/2011/05/centos-55php-53.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/212914301342496384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4798799528175341639/posts/default/212914301342496384'/><link rel='alternate' type='text/html' href='http://jayhsunote.blogspot.com/2011/05/centos-55php-53.html' title='CentOS 5.5中PHP升級至 5.3的方法'/><author><name>Jayhsu</name><uri>http://www.blogger.com/profile/07807801620529099380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>