Monday, January 29, 2007 - 文章

中文編碼解析工具1.1版

之前發表過一個小工具--Unicode編碼解析小工具,當時小熊子建議加上URLEncode的功能。

今天剛好又幫同事解決big5 ASP頁面上要顯示Unicode文字的問題,此時會用到犇這種表示法(用過很多次,今天才知道這種表示法的正確名稱叫做Numeric Character Reference,NCR)。

以前要查NCR,我都是在FrontPage中輸入難字,再去HTML View看轉換後的結果。不過FrontPage不是人人都有安裝,我索性就將它也加到編碼解析工具中,連同上次小熊子提的UrlEncode,一口氣再多支援三種編輯轉換。而UrlEncode與NCR的編碼欄位支援編輯功能,可輸入編碼還原回中文的功能,拿來轉換URL Query String或HTML中的NCR很有用。有需要的朋友可以下載回去玩!

** 注意: 執行前請先確認有安裝.NET 2.0 Framework。

下載: 中文編碼解析工具1.1版

為Reporting Service加上密碼式參數輸入

需求是這樣的,當我們利用/ReportServer方式檢視Reporting Service報表,網頁上會自動產生輸入參數的TextBox WebControl,說穿了就是一個個<input type="text">,如果其中有些參數具有機密性,希望能以<input type="password">方式呈現,Reporting Service目前是無法支援的。

Reporting Service提供了兩種客製化報表檢視網頁的方法,第一種是用rs:Stylesheet Query String指定CSS檔,原本我找到了用body { background=url("BLOCKED SCRIPT...") }的做法,很不幸地,在IE7上,CSS裡內嵌的Javascript似乎會被忽略(應是基於安全的考量吧),所以只好轉向使用第二種做法,修改C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer\Pages\ReportViewer.aspx。

我的構想是這樣的,我們以參數輸入提示文字中夾帶了(*)字樣作為信物,例如: "請輸入密碼(*)",在ReportViewer.aspx的最後方加入以下的Javascript Code,就可以為這些需要隱藏輸入內容的欄位新增一個<input type="password">的密碼輸入方格,在onblur時,將值填入真正的<input type="text">中。而為了避免真正的text input洩漏天機,可利用inp.style.postion="absolute"; inp.style.left="-1000px";的技巧把它藏到火星去。最後,由於password input沒有記憶功能,在Post-Back後會自動清空,所以我們要記得在每次Post-Back時將text input中的值抄回password input,如此,就大功告成了!

</form>
<script>

var tds=document.getElementsByTagName("TD");
for (var i=0; i<tds.length; i++) {
  var td=tds[i];
  if (td.className=="ParamLabelCell" && td.innerText.indexOf("(*)")>0)
  {
    td.innerText=td.innerText.replace("(*)","");
    var inpSpan=td.nextSibling.children[0];
    var origInp=inpSpan.children[0];
    var pwdInp=document.createElement("INPUT");
    inpSpan.appendChild(pwdInp);
    pwdInp=inpSpan.children[1];
    pwdInp.outerHTML="<INPUT type='password' onblur='document.all(\""
        + origInp.id +"\").value=this.value;' value='" + origInp.value + "' />";
    origInp.style.position="absolute";
    origInp.style.left="-1000px";
  }
}

</script>

其產生效果如下圖:

搜尋

Go

<January 2007>
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910
 
RSS
最新回應


BlogLook Score and Rank

Syndication