(HttpContext.Current.CurrentHandler as Page).ResolveUrl(path);
2013年12月2日 星期一
2013年11月15日 星期五
ms sql subquery
昨天一個朋友問我一個sql子查詢相關的問題,好險這幾年下來也累積了不少sql語法的經驗,這邊順便將結果記錄下來
一個table中有 a_uid和b_uid兩個欄位,如何將有不同b_uid的a_uid抓出來
資料
執行結果
一個table中有 a_uid和b_uid兩個欄位,如何將有不同b_uid的a_uid抓出來
資料
執行結果
完整語法如下
select * from (select COUNT(distinct(b_uid)) as num,a_uid from tbl_test3
where a_uid in(select a_uid from tbl_test3) group by a_uid) as a where
a.num>1
2013年11月6日 星期三
get like count using fql
https://developers.facebook.com/tools/explorer/?fql=select%20caption%2Clike_info%20from%20photo%20where%20owner%3D701888397
select caption,like_info from photo where owner=701888397
select caption,like_info from photo where owner=701888397
2013年11月5日 星期二
c# convert utf8 to big5
public string ConvertBig5(string strUtf)
{
System.Text.Encoding utf81 = System.Text.Encoding.GetEncoding("utf-8");
System.Text.Encoding big51 = System.Text.Encoding.GetEncoding("big5");
Response.ContentEncoding = big51;
byte[] strUtf81 = utf81.GetBytes(strUtf.Trim());
byte[] strBig51 = System.Text.Encoding.Convert(utf81, big51, strUtf81);
char[] big5Chars1 = new char[big51.GetCharCount(strBig51, 0, strBig51.Length)];
big51.GetChars(strBig51, 0, strBig51.Length, big5Chars1, 0);
string tempString1 = new string(big5Chars1);
return tempString1;
}
{
System.Text.Encoding utf81 = System.Text.Encoding.GetEncoding("utf-8");
System.Text.Encoding big51 = System.Text.Encoding.GetEncoding("big5");
Response.ContentEncoding = big51;
byte[] strUtf81 = utf81.GetBytes(strUtf.Trim());
byte[] strBig51 = System.Text.Encoding.Convert(utf81, big51, strUtf81);
char[] big5Chars1 = new char[big51.GetCharCount(strBig51, 0, strBig51.Length)];
big51.GetChars(strBig51, 0, strBig51.Length, big5Chars1, 0);
string tempString1 = new string(big5Chars1);
return tempString1;
}
2013年11月1日 星期五
2013年10月22日 星期二
adjust select width in jquerymobile table
$(document).ready(function(){
$.mobile.ajaxEnabled = false;
$(".ui-select").each(function () {
$(this).css({ 'width': $(this).parent().width() + 'px' });
});
$(".ui-select").css("display", "");
$(".ui-select").show();
});
$(window).resize(function () {
$(".ui-select").hide();
$(".ui-select").each(function () {
$(this).css({ 'width': $(this).parent().width() + 'px' });
});
$(".ui-select").css("display", "");
$(".ui-select").show();
});
///
2013/11/01 update
maybe we can use below function to change width, it's easier to use
$('#select_menu_id').selectmenu('refresh');
$.mobile.ajaxEnabled = false;
$(".ui-select").each(function () {
$(this).css({ 'width': $(this).parent().width() + 'px' });
});
$(".ui-select").css("display", "");
$(".ui-select").show();
});
$(window).resize(function () {
$(".ui-select").hide();
$(".ui-select").each(function () {
$(this).css({ 'width': $(this).parent().width() + 'px' });
});
$(".ui-select").css("display", "");
$(".ui-select").show();
});
///
2013/11/01 update
maybe we can use below function to change width, it's easier to use
$('#select_menu_id').selectmenu('refresh');
2013年10月17日 星期四
sandcastle 為你的程式產生說明文件
每次比較大的案件要結案時客戶總是會要求一些程式說明文件,這個是很讓人頭痛的尤其是很喜歡改來改去的客戶,到最後根本沒辦法依照當初規劃的文件去產生程式說明。
sandcastle這個軟體可以產生chm和html檔的說明文件,最主要是在程式撰寫時必須在每個class中寫好註解如下
///
/// bank 的摘要描述
///
public class bank : IDisposable{
///
/// 新增銀行資訊
///
/// 銀行代碼
/// 銀行名稱
///int
public int add(string code, string bankname)
{
..................
}
...................
}
接下來在.net的指令模式下執行下列指令產生xml文件
C:\文件要產生的路徑>csc /doc:bank.xml /recurse:App_Code\*.cs /reference:Bin\NPOI.dll,BIN\Ionic.Zip.dll,Bin\DocX.dll,Bin\AntiXSSLibrary.dll
產生出來的xml再利用sandcastle軟體產生說明文件即可,下面的global項目要勾選才會產生所有class的說明文件哦
參考資料
http://msdn.microsoft.com/en-us/library/ms379563%28v=vs.80%29.aspx
http://sandcastle.codeplex.com/
sandcastle這個軟體可以產生chm和html檔的說明文件,最主要是在程式撰寫時必須在每個class中寫好註解如下
///
/// bank 的摘要描述
///
public class bank : IDisposable{
///
/// 新增銀行資訊
///
/// 銀行代碼
/// 銀行名稱
///
public int add(string code, string bankname)
{
..................
}
...................
}
接下來在.net的指令模式下執行下列指令產生xml文件
C:\文件要產生的路徑>csc /doc:bank.xml /recurse:App_Code\*.cs /reference:Bin\NPOI.dll,BIN\Ionic.Zip.dll,Bin\DocX.dll,Bin\AntiXSSLibrary.dll
產生出來的xml再利用sandcastle軟體產生說明文件即可,下面的global項目要勾選才會產生所有class的說明文件哦
參考資料
http://msdn.microsoft.com/en-us/library/ms379563%28v=vs.80%29.aspx
http://sandcastle.codeplex.com/
2013年10月8日 星期二
使用System.Net.WebRequest代替傳統的取代方式來取得郵件範本
今天同事分享了一個方式可以取代之前的方式來取得郵件的內容
利用System.Net.WebRequest可以直接抓取已執行過的.net頁面資料的html
這樣子一來就可以直接發送了,就不需要開啟檔案再將字串取代了
System.Net.WebRequest request = System.Net.WebRequest.Create(epaperPage + "?id=" + param_mailid);
System.Net.WebResponse response = request.GetResponse();
string contents;
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
contents = reader.ReadToEnd();
reader.Close();
}
response.Close();
利用System.Net.WebRequest可以直接抓取已執行過的.net頁面資料的html
這樣子一來就可以直接發送了,就不需要開啟檔案再將字串取代了
System.Net.WebRequest request = System.Net.WebRequest.Create(epaperPage + "?id=" + param_mailid);
System.Net.WebResponse response = request.GetResponse();
string contents;
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
contents = reader.ReadToEnd();
reader.Close();
}
response.Close();
2013年10月7日 星期一
win 7網路芳鄰不能連線
今天同事的電腦忽然無法連線到網路磁碟機,一直找不到原因,問過google後找到一篇網誌,最主要是網路位置不能選擇公用網路,應該是因為安全性的關係吧,相關文章如下:
http://tlcheng.wordpress.com/2010/12/12/win7%E9%9C%80%E4%BD%BF%E7%94%A8%E7%B6%B2%E8%B7%AF%E8%8A%B3%E9%84%B0%E9%80%A3%E5%85%A5%E6%99%82%E7%B6%B2%E8%B7%AF%E4%BD%8D%E7%BD%AE%E5%88%A5%E4%BA%82%E9%81%B8/
http://tlcheng.wordpress.com/2010/12/12/win7%E9%9C%80%E4%BD%BF%E7%94%A8%E7%B6%B2%E8%B7%AF%E8%8A%B3%E9%84%B0%E9%80%A3%E5%85%A5%E6%99%82%E7%B6%B2%E8%B7%AF%E4%BD%8D%E7%BD%AE%E5%88%A5%E4%BA%82%E9%81%B8/
2013年10月2日 星期三
解決不同瀏覽器的css規範
可以使用 reset.css 或 normalize.css 來重新設定不同瀏覽器時不同元素的預設值,這樣子在debug時會節省許多時間,有一些網站提供連結下載可直接使用的檔案
http://necolas.github.io/normalize.css/
http://necolas.github.io/normalize.css/
2013年9月24日 星期二
2013年9月18日 星期三
javascript regex 判斷輸入格式
//判斷只能輸入英文和數字
var reg = /^[\d|a-zA-Z]+$/;
if (!reg.test($("#pwd_").val())) {
//錯誤訊息
}
//判斷Email
var testmail = /^.+@.+\..{2,3}$/;
if (!testmail.test($('#email').val()) || $('#email').val().indexOf('.', 1) == -1) {
//錯誤訊息
}
//判斷電話
var reg= new RegExp(/^(\((0([2-9]){1,4})\))?(\s)?(([2-9]){1}[0-9]{5,7}){1}(\s)?(\#(\s)?[0-9]{1,8})?$/);
if (!reg.test($("#phone").val())) {
//錯誤訊息
}
//判斷中文
var reg = /^[\u4e00-\u9fa5] +$/;
if (!reg.test($("#name").val())) {
//錯誤訊息
}
訂閱:
意見 (Atom)