2012年12月6日 星期四
{JavaScript} JS控制控制項Enable、Visible
// Visible 不顯示(不出現在Html中)
if ($('#<%=select.ClientID%>').find("option:selected").val() != '我選了')
$('#<%=trCPSDMailNotice.ClientID%>').attr('style', 'display:none');
//出現
else
$('#<%=trCPSDMailNotice.ClientID%>').attr('style', 'display:');
//Enable 顯示但不可用
if (!$('#<%=chkBoth.ClientID%>')[0].checked)
$('#<%=txtMyFare.ClientID%>').attr('disabled', 'disabled');
//顯示且可用
else
$('#<%=txtMyFare.ClientID%>').removeAttr('disabled');
2012年11月9日 星期五
{Note} SSD與Ghost相關文章
1.不要Ghost和重装 两招把Win7克隆到SSD
http://www.mcplive.cn/index.php/article/index/id/11085/page/2
2.简单易上手 SSD装Win7系统的三种办法
http://ssd.zol.com.cn/306/3063938.html
3.Crucial m4 128GB mSATA SSD-安裝篇
http://blog.xuite.net/walf/life/63296773#axzz2AeU1dWcT
4.關於ssd使用ghost
http://www.mobile01.com/topicdetail.php?f=490&t=2895090&p=1
5.請教 安裝SSD前.後 應該做的事??
http://5i01.com/topicdetail.php?f=490&t=2560701&p=1
6.Windows 7 安裝固態硬碟SSD系統碟簡單、傻瓜優化
http://hikari-solving.blogspot.tw/2012/05/windows-7-ssd.html
http://www.mcplive.cn/index.php/article/index/id/11085/page/2
2.简单易上手 SSD装Win7系统的三种办法
http://ssd.zol.com.cn/306/3063938.html
3.Crucial m4 128GB mSATA SSD-安裝篇
http://blog.xuite.net/walf/life/63296773#axzz2AeU1dWcT
4.關於ssd使用ghost
http://www.mobile01.com/topicdetail.php?f=490&t=2895090&p=1
5.請教 安裝SSD前.後 應該做的事??
http://5i01.com/topicdetail.php?f=490&t=2560701&p=1
6.Windows 7 安裝固態硬碟SSD系統碟簡單、傻瓜優化
http://hikari-solving.blogspot.tw/2012/05/windows-7-ssd.html
{C#} ajax call WebMethod &ashx 應用
一、WebMethod :
aspx:
var strURL = 'WebForm2.aspx/GetValue';
$.ajax({
type: 'POST',
url: strURL,
data: "{'orderNo':'" + value + "'}",//傳入參數
contentType: "application/json; charset=utf-8",
dataType: 'json',
error: function (xhr, ajaxOptions, thrownError) {
alert('Ajax request 發生錯誤 ' + xhr.responseText);
},
success: function (html) {
var dataArr = JSON.parse(html.d);
}
WebForm2.aspx.cs:
[WebMethod]
public static string GetValue(string orderNo)
{
object temp = new object();
temp = DateTime.Now.ToString("yyyy");
var data = new JavaScriptSerializer().Serialize(temp);
return data;
}
二、ashx 應用
aspx:
var value = $('#<%=txtOrderNo.ClientID %>').val();
var customer = $('#<%=lblCustomerNo.ClientID %>').text();
var strURL = 'OrderDetailSource.ashx';
$.ajax({
type: 'GET',
url: strURL,
data: { orderNo: value, customerId: customer },
contentType: "application/json; charset=utf-8",
dataType: 'json',
error: function (xhr, ajaxOptions, thrownError) {
alert('Ajax request 發生錯誤 ' + xhr.responseText);
},
success: function (result) {
//result 直接就是一個json
alert(result[0].屬性);
}});
OrderDetailSource.ashx:
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
//傳入的參數
string orderNo = context.Request.QueryString["orderNo"] ?? string.Empty;
string customerId = context.Request.QueryString["customerId"] ?? string.Empty;
//service 2.0 寫法
var result = new Service.Operator().abc(orderNo, customerId);
var temp = JsonConvert.SerializeObject(result, Formatting.Indented);
//回傳一個json格式資料
context.Response.Write(temp);
}
註:
當用方法二時,type要為GET,因為有傳入參數,用Post會直接跑error
參考資料:
http://www.dotblogs.com.tw/threeday0905/archive/2011/01/07/20648.aspx
http://zh-tw.yescript.com/JavascriptScripts-67-.ajaxFanHuiDeJSONWuF/
http://blog.sina.com.cn/s/blog_5ee49d5a0100ss13.html
xhr error message 屬性方法
http://kevyu.blogspot.tw/2010/06/ajaxerror-message.html
Jquery ajax 屬性值列表
http://www.w3school.com.cn/jquery/ajax_ajax.asp
//下面這個範例的$.toJSON({ ids : id })試不出來
http://www.dotblogs.com.tw/rx836/archive/2011/05/10/24658.aspx
aspx:
var strURL = 'WebForm2.aspx/GetValue';
$.ajax({
type: 'POST',
url: strURL,
data: "{'orderNo':'" + value + "'}",//傳入參數
contentType: "application/json; charset=utf-8",
dataType: 'json',
error: function (xhr, ajaxOptions, thrownError) {
alert('Ajax request 發生錯誤 ' + xhr.responseText);
},
success: function (html) {
var dataArr = JSON.parse(html.d);
}
WebForm2.aspx.cs:
[WebMethod]
public static string GetValue(string orderNo)
{
object temp = new object();
temp = DateTime.Now.ToString("yyyy");
var data = new JavaScriptSerializer().Serialize(temp);
return data;
}
二、ashx 應用
aspx:
var value = $('#<%=txtOrderNo.ClientID %>').val();
var customer = $('#<%=lblCustomerNo.ClientID %>').text();
var strURL = 'OrderDetailSource.ashx';
$.ajax({
type: 'GET',
url: strURL,
data: { orderNo: value, customerId: customer },
contentType: "application/json; charset=utf-8",
dataType: 'json',
error: function (xhr, ajaxOptions, thrownError) {
alert('Ajax request 發生錯誤 ' + xhr.responseText);
},
success: function (result) {
//result 直接就是一個json
alert(result[0].屬性);
}});
OrderDetailSource.ashx:
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
//傳入的參數
string orderNo = context.Request.QueryString["orderNo"] ?? string.Empty;
string customerId = context.Request.QueryString["customerId"] ?? string.Empty;
//service 2.0 寫法
var result = new Service.Operator().abc(orderNo, customerId);
var temp = JsonConvert.SerializeObject(result, Formatting.Indented);
//回傳一個json格式資料
context.Response.Write(temp);
}
註:
當用方法二時,type要為GET,因為有傳入參數,用Post會直接跑error
參考資料:
http://www.dotblogs.com.tw/threeday0905/archive/2011/01/07/20648.aspx
http://zh-tw.yescript.com/JavascriptScripts-67-.ajaxFanHuiDeJSONWuF/
http://blog.sina.com.cn/s/blog_5ee49d5a0100ss13.html
xhr error message 屬性方法
http://kevyu.blogspot.tw/2010/06/ajaxerror-message.html
Jquery ajax 屬性值列表
http://www.w3school.com.cn/jquery/ajax_ajax.asp
//下面這個範例的$.toJSON({ ids : id })試不出來
http://www.dotblogs.com.tw/rx836/archive/2011/05/10/24658.aspx
{C#} Gridview 加一欄為流水號欄位
<asp:TemplateField HeaderText="No" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<%# (Container.DataItemIndex+1).ToString()%>
</ItemTemplate>
</asp:TemplateField>
參考資料:
http://www.dotblogs.com.tw/petedotnet/archive/2009/01/11/6733.aspx
{C#} 呼叫靜態Fucntion
建立一靜態Function
public class abc
{
public static DataTable ReadData(string commStr)
{
return new DataTable();
}
}
//呼叫靜態Function
var resultDt = abc.ReadData(strComm);
使用靜態:
當只有單個function呼叫此靜態function時使用,以不使變數資料錯亂
Ex:計算來站人數
參考資料:
http://msdn.microsoft.com/zh-tw/library/98f28cdx%28VS.80%29.aspx
http://www.oreilly.com.tw/column_sleepless.php?id=j021
http://www.blueshop.com.tw/board/FUM20050124192253INM/BRD20101210144748M1L.html
http://www.dotblogs.com.tw/kkman021/archive/2011/08/17/33357.aspx
2012年10月25日 星期四
{C#} Dictionary Custom Key is class
如 Dictionary的key 值是客製,從class而來
如要讓Dictionary裡的key不重覆,需覆寫GetHashCode()與Equals(object obj)
Dictionary.ContainsKey() 才會有效果
EX:
Dictionary<ErrorData, string> dicTemp = new Dictionary<ErrorData, string>();
ErrorData er=new ErrorData();
er.CUR="abc";
er.Name="Jake";
if (!dicTemp.ContainsKey(er))
dicTemp.Add(er,"good");
建立類別
public class ErrorData
{
public string CUR{ set; get; }
public string Name{ set; get; }
public override int GetHashCode()
{
//return base.GetHashCode();
return Name.GetHashCode() ^ CUR.GetHashCode();
}
public override bool Equals(object obj)
{
ErrorData v1 = obj as ErrorData;
return v1.PN == PN && v1.Currency == Currency;
}
}
參考資料:
http://www.cnblogs.com/pmars/archive/2012/03/02/2376610.html
如要讓Dictionary裡的key不重覆,需覆寫GetHashCode()與Equals(object obj)
Dictionary.ContainsKey() 才會有效果
EX:
Dictionary<ErrorData, string> dicTemp = new Dictionary<ErrorData, string>();
ErrorData er=new ErrorData();
er.CUR="abc";
er.Name="Jake";
if (!dicTemp.ContainsKey(er))
dicTemp.Add(er,"good");
建立類別
public class ErrorData
{
public string CUR{ set; get; }
public string Name{ set; get; }
public override int GetHashCode()
{
//return base.GetHashCode();
return Name.GetHashCode() ^ CUR.GetHashCode();
}
public override bool Equals(object obj)
{
ErrorData v1 = obj as ErrorData;
return v1.PN == PN && v1.Currency == Currency;
}
}
參考資料:
http://www.cnblogs.com/pmars/archive/2012/03/02/2376610.html
2012年10月24日 星期三
{C#} enum 使用
//列舉排序的選項
public enum Rank:int
{
中文, 中文二, 中文三
}
列舉中各代表的數值(預設)
中文=0
中文二=1
中文三=2
//將一文字值轉為Enum
(Rank) Enum.Parse(typeof (Rank), Value);
//取得Enum的所有值
Enum.GetNames(typeof (Rank))
>>string[0] 中文 string[1] 中文二 string [2] 中文三
//宣告 rank變數為一個Enum Rank形態
Rank rank=Rank.中文;
switch ((int)rank)
{
case 0://中文
return finalResult.OrderBy(s => s.Code).ToList();
case 1://中文二
return finalResult.OrderBy(s => s.Sourer).ToList();
case 2://中文三
return finalResult.OrderByDescending(s => s.AllYearCurrencyRate).ToList();
}
參考資料:
http://www.dotblogs.com.tw/johnny/archive/2010/01/25/13300.aspx
http://diary.tw/tim/743
public enum Rank:int
{
中文, 中文二, 中文三
}
列舉中各代表的數值(預設)
中文=0
中文二=1
中文三=2
//將一文字值轉為Enum
(Rank) Enum.Parse(typeof (Rank), Value);
//取得Enum的所有值
Enum.GetNames(typeof (Rank))
>>string[0] 中文 string[1] 中文二 string [2] 中文三
//宣告 rank變數為一個Enum Rank形態
Rank rank=Rank.中文;
switch ((int)rank)
{
case 0://中文
return finalResult.OrderBy(s => s.Code).ToList();
case 1://中文二
return finalResult.OrderBy(s => s.Sourer).ToList();
case 2://中文三
return finalResult.OrderByDescending(s => s.AllYearCurrencyRate).ToList();
}
參考資料:
http://www.dotblogs.com.tw/johnny/archive/2010/01/25/13300.aspx
http://diary.tw/tim/743
訂閱:
文章 (Atom)