2013年4月30日 星期二

{C#} To List 轉Json 方式

方法一:
.Net 內 建

using System.Web.Script.Serialization;

var modelList = abc.ToArray();
var stringTemp = new JavaScriptSerializer().Serialize(modelList);


方法二:
另外載入DLL
using Newtonsoft.Json;
var modelList = abc.ToArray();
var turnToJson = JsonConvert.SerializeObject(modelList , Formatting.Indented);

2013年4月19日 星期五

{C#} const & static 差異

Const 與 Static都屬不可被變動的變數設定
Const 存放的變數是非動態值
Static 則存放動態值

Example:

    public const int c2 = c1 + 1;     public static int s1 = 6;         c1 = s1;  //錯誤         s1 = c2+1;         Label2.Text = "const:" + c1 + " const2:" + c2 + " static:" + s1; OutPut:

const:5 const2:6 static:7

參考資訊:
http://www.dotblogs.com.tw/kim/archive/2009/05/11/const.aspx

2013年4月17日 星期三

{C#} .Net FileUpload 上傳檔案大小超過預設


當上傳檔案後,出現「Maximum Request Length Exceeded」
是因為上傳的檔案超過預設大小
預設為4096>>4MB  

異動如下:
<system.web>
      <httpRuntime maxRequestLength="10240"  />
    </system.web>



參考資訊
http://www.dotblogs.com.tw/hatelove/archive/2010/01/14/fileuploadmaxrequestlengthtocustomerrorpage.aspx

2013年4月1日 星期一

{Other} 架設網站

1.DropBox 加大空間方法>
http://gcchiou.pixnet.net/blog/post/27309588-%E3%80%90%E8%BD%89%E8%BC%89%E3%80%91%E9%9D%A0%E8%87%AA%E5%B7%B1%E5%B0%B1%E5%8F%AF%E4%BB%A5%E5%BE%97%E5%88%B0%E5%85%8D%E8%B2%BB18g%E7%9A%84dropbox%E7%A9%BA



太重要的文章:如何把Drop box當 js 存放地給引用
http://www.study-test.com/2012/09/10/388/



2.SOMEE 國外伺服器,中文網頁(aspx)會有問題
https://somee.com/default.aspx

2013年2月27日 星期三

{JQuery}倒數計時器(Like hTC時鐘效果)

當到數十秒結束後,將saveBtn 效果Open

JavaScript:
function timerStart() {
            $("span").each(function () {
                $(this).attr('style', 'display');
            });
            //只有秒數
            $('.counter').counter({ format: '59' });
            //事件:counterStop
            $('.counter').live('counterStop', function () {
                $('#<%=saveBtn.ClientID %>').removeAttr('disabled');
            });
         }


Html:
<asp:Button ID="saveBtn" runat="server" Text="Upload" class="btnred" />

<span id="spanCounterWord" style="display:none" >等待</span>
                <span class="counter  counter-analog" id="spanCounter" style="display:none" >0:10</span>
                <span id="spanCounterWord2" style="display:none" >秒後,即可再度上傳</span>


註1:在API中綁定counterStop事件用 on , 其為jQuery UI版本為1.7以上才能使用,
        1.7以下的版本使用 live 綁定
註2:each 使用如下Sample:

$("span").each(function () {
});


$("span[dir='value']").each(function(){
});


API:
http://blog.sophilabs.com/2012/08/jquery-counter-plugin/

JS 綁定事件
http://blog.wu-boy.com/2012/04/use-on-api-to-attach-event-handlers-on-jquery/

each 瀏覽標籤
http://stackoverflow.com/questions/1936411/return-the-text-of-each-span-using-jquery
API:
http://api.jquery.com/each/
參考資料:
http://stackoverflow.com/questions/1936411/return-the-text-of-each-span-using-jquery

2013年1月23日 星期三

{JQuery} 函式 運用 (更新時間:04/09)

1.函式:$.map(source,function (item)
解釋:列出陣列中資料(JSON. ARRAY)
範例:

$.map(JSON.parse($("#<%=Source.ClientID %>").val()),function (item) {
    $('#<%=ddlAAA.ClientID%>').append($('<option value=' + item+ '>' + item  + '</option>'));
                            })

參考資料:http://api.jquery.com/jQuery.map/



2.函式:$.grep(source, function (item)
解釋:比對外來資料與陣列中的資料(JSON. ARRAY)
範例:

$.map(source,function (item) {

  $.grep(JSON.parse($("#<%=Source.ClientID %>").val()), function (item) {
                        return (new RegExp("^" + $.ui.autocomplete.escapeRegex(request.term), "i")).test(item);
                    })


參考資料:http://api.jquery.com/jQuery.grep/

2013年1月3日 星期四

{JavaScript} html控制項利用JS Bind事件


$('#btnAdd').bind('click', function () {
                        var qty = $('#txtQty').val() != '' ? parseInt($('#txtQty').val()) : 0;
                        var sum = $('#hiddenText').val() != '' ? parseInt($('#hiddenText').val()) : 0;
                        var total = qty + sum;
                        $('#hiddenText').val(total);
                        alert($('#hiddenText').val());
                    })

<input type="button" id="btnAdd" value="加入" />

按鈕btnAdd利用JS語法,Bind 住 Click事件

參考資料:
http://stackoverflow.com/questions/6458840/on-input-change-event