本文為翻譯,英文原版的Cheat Sheet(PDF版本)在此下載:http://aspnetresources.com/downloads/ms_ajax_library_cheat_sheets1.zip
原作著作權聲明:
Copyright (c) 2004-2006, Milan Negovanhttp://www.AspNetResources.comAll rights reserved.Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditionsare met:* Redistributions of source code must retain the above copyrightnotice, this list of conditions and the following disclaimer.* Redistributions in binary form must reproduce the above copyrightnotice, this list of conditions and the following disclaimer inthe documentation and/or other materials provided with thedistribution.* The name of the author may not be used to endorse or promote productsderived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITEDTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULARPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER ORCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OROTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IFADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
註:標註有[S]的為靜態方法,無須執行個體化對象即可使用。
[S] Boolean.parse (value )
從字串表示的布爾值解析成相應的Boolean類型。value參數必須為“true”或“false”二者之一,不區分大小寫,且可以包含空格。
var b = Boolean.parse("true");
Date.format (format)
格式化字串(地區設定無關)。
var d = new Date();
Sys.Debug.trace (d.format("dddd, dd MMMM yyyy HH:mm:ss"));
Date.localeFormat (format)
格式化字串(地區設定相關)。使用Sys.CultureInfo.CurrentCulture得到地區屬性。
var d = new Date();
Sys.Debug.trace (d.localeFormat("dddd, dd MMMM yyyy HH:mm:ss"));
[S] Date.parseLocale (value, formats)
從字串表示的本地時間日期解析成相應的Date類型。使用Sys.CultureInfo.CurrentCulture得到地區屬性。
Sys.Debug.trace (Date.parseLocale ("4/10/2001", "yyyy-MM-dd",
"MM/dd/yyyy"));
// Date.parseLocale will skip the first format here as invalid and use
// the second one. If it does not find an appropriate format,
// the function throws an exception.
[S] Date.parseInvariant (value, formats)
從字串表示的地區無關時間日期解析成相應的Date類型。
Sys.Debug.trace (Date.parseInvariant ("4/10/2001", "yyyy-MM-dd",
"MM/dd/yyyy"));
// Date.parseInvariant will skip the first format here as invalid and use
// the second one. If it does not find an appropriate format,
// the function throws an exception.
支援的格式
- d: 縮寫日期(e.g.: 02/17/2007):
- D: 完整日期(e.g: Saturday, 17 February 2007)
- t: 縮寫時間(e.g.: 22:10)
- T: 完整時間(e.g.: 22:10:30)
- F: 完整時間日期(e.g.: Saturday, 17 February 2007 22:10:30)
- m (or M): 月和日(e.g.: February 17)
- s: 可排序的時間日期(e.g.: 2007-02-17T22:10:30)
- y (or Y): 年和月(e.g.: 2007 February)