All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
减轻javascript测试和调试负担_JavaScript技术_编程技术
visual c++添加菜单命令处理函数
实用技巧,利用Apache实现禁止图片盗链_php资料_编程技术
DropDownList,绑定数据库中的字段获取下拉列表值_[Asp.Net教程]
SQL中的DDL,DML,DCL语言_mssql学习_编程技术
ASP.NET从零起步设计网站全过程(8)_[Asp.Net教程]
C#中设置窗体的属性
visit c++中Connection与Recordset
ASP.NET,MVC,Framework体验(2):显示列表数据_[Asp.Net教程]
利用OpenSmtp.Net发送需要smtp验证的邮件_[Asp.Net教程]
Reading number is top 10 pictures
Average female college students3
男人帮杂志里的惹火性感美女1
福利福利。。。。。。
狗狗与主人神同步1
刘亦菲写真集1
看到这个手速,决定过年就让我家猫帮我抢红包了。。
The dog buy the ham oneself
The real super beauty12
So beauty, will let you spray blood3
2012 national geographic daily picture6
Download software ranking
Tram sex maniac 2 (H) rar bag4
Boxer's Top ten classic battle5
Eclipse 4.2.1 For Win32
asp.netWeb服务器高级编程
C++教程第四版
豪门浪荡史
Tram sex maniac 2 (H) rar bag6
仙剑奇侠传98硬盘WINXP版
SP3 for SQL2000
Boxer's Top ten classic battle8
归海一刀 published in(发表于) 2014/1/30 1:11:10 Edit(编辑)
新瓶旧酒ASP.NET,AJAX(7),-,客户端脚本编程(Sys命名空间下的类)_[Asp.Net教程]

新瓶旧酒ASP.NET,AJAX(7),-,客户端脚本编程(Sys命名空间下的类)_[Asp.Net教程]

新瓶旧酒ASP.NET AJAX(7) - 客户端脚本编程(Sys命名空间下的类)_[Asp.Net教程]























新瓶旧酒ASP.NET AJAX(7) - 客户端脚本编程(Sys命名空间下的类)


介绍
Sys命名空间是Microsoft AJAX Library的根命名空间。本文主要学习一下其中的Application类、ApplicationLoadEventArgs类、CultureInfo类和StringBuilder类。





关键
1、Application Class
·init事件 - 脚本加载完毕,对象创建之前。
·load事件 - 对象被创建和初始化。可以用pageLoad()
·unload事件 - window.unload时。可以用pageUnload()
·notifyScriptLoaded() - 通知ScriptManager某段脚本已经加载完毕




2、ApplicationLoadEventArgs Class
·components - 最后一次触发load事件时创建的Components
·isPartialLoad - 是否是部分刷新




3、CultureInfo Class
·CurrentCulture字段 - 当前的Culture,返回CurrentCulture对象
·name字段 - Culture的名称
·dateTimeFormat - 获得dateTimeFormat对象,其内有n多格式化类型
·numberFormat - 获得numberFormat对象,其内有n多格式化类型




4、StringBuilder Class
·append(text) - 添加指定字符串到StringBuilder对象的结尾
·appendLine() - 添加一个换行符到StringBuilder对象的结尾
·appendLine(text) - 添加指定字符串到StringBuilder对象的结尾并添加一个换行符
·clear() - 清除StringBuilder对象所有内容
·isEmpty() - StringBuilder对象的内容是否为空
·toString() - 将StringBuilder对象的内容转换为字符串
·toString(separator) - 在StringBuilder对象内的每一个元素的结尾处添加指定字符串




5、其它请查看官方文档





示例
CustomButton.js
Type.registerNamespace("Demo");




Demo.CustomButton = function(element)
{
// 该类继承自Sys.UI.Control,调用基类构造函数
Demo.CustomButton.initializeBase(this, [element]);




this._clickDelegate = null;
this._hoverDelegate = null;
this._unhoverDelegate = null;
}
Demo.CustomButton.prototype =
{
// 定义text属性 - 元素显示的信息
get_text: function()
{
// element - Sys.UI.Control的属性
return this.get_element().innerHTML;
},
set_text: function(value)
{
this.get_element().innerHTML = value;
},




// 添加或移除click事件
add_click: function(handler)
{
// events - Sys.Component的属性
this.get_events().addHandler(’click’, handler);
},
remove_click: function(handler)
{
this.get_events().removeHandler(’click’, handler);
},

// 添加或移除hover事件
add_hover: function(handler)
{
this.get_events().addHandler(’hover’, handler);
},
remove_hover: function(handler)
{
this.get_events().removeHandler(’hover’, handler);
},




// 添加或移除unhover事件
add_unhover: function(handler)
{
this.get_events().addHandler(’unhover’, handler);
},
remove_unhover: function(handler)
{
this.get_events().removeHandler(’unhover’, handler);
},




// 释放资源
dispose: function()
{
var element = this.get_element();




if (this._clickDelegate)
{
// Sys.UI.DomEvent removeHandler()
removeHandler(element, ’click’, this._clickDelegate);
delete this._clickDelegate;
}




if (this._hoverDelegate)
{
removeHandler(element, ’focus’, this._hoverDelegate);
removeHandler(element, ’mouseover’, this._hoverDelegate);
delete this._hoverDelegate;
}




if (this._unhoverDelegate)
{
removeHandler(element, ’blur’, this._unhoverDelegate);
removeHandler(element, ’mouseout’, this._unhoverDelegate);
delete this._unhoverDelegate;
}
Demo.CustomButton.callBaseMethod(this, ’dispose’);
},




// 初始化
initialize: function()
{
var element = this.get_element();




if (!element.tabIndex) element.tabIndex = 0;




if (this._clickDelegate === null)
{
// Function.createDelegate用来创建一个调用“this”上下文下的特定函数的委托
this._clickDelegate = Function.createDelegate(this, this._clickHandler);
}
// Sys.UI.DomEvent addHandler()
addHandler(element, ’click’, this._clickDelegate);




if (this._hoverDelegate === null)
{
this._hoverDelegate = Function.createDelegate(this, this._hoverHandler);
}
addHandler(element, ’mouseover’, this._hoverDelegate);
addHandler(element, ’focus’, this._hoverDelegate);




if (this._unhoverDelegate === null)
{
this._unhoverDelegate = Function.createDelegate(this, this._unhoverHandler);
}
addHandler(element, ’mouseout’, this._unhoverDelegate);
addHandler(element, ’blur’, this._unhoverDelegate);




Demo.CustomButton.callBaseMethod(this, ’initialize’);
},

// click事件处理器
_clickHandler: function(event)
{
var h = this.get_events().getHandler(’click’);
if (h) h(this, Sys.EventArgs.Empty);
},
// hover事件处理器
_hoverHandler: function(event)
{
var h = this.get_events().getHandler(’hover’);
if (h) h(this, Sys.EventArgs.Empty);
},
// unhover事件处理器
_unhoverHandler: function(event)
{
var h = this.get_events().getHandler(’unhover’);
if (h) h(this, Sys.EventArgs.Empty);
}
}
Demo.CustomButton.registerClass(’Demo.CustomButton’, Sys.UI.Control);




// 通知ScriptManager这段脚本已经加载完毕
if (typeof(Sys) !== ’undefined’) Sys.Application.notifyScriptLoaded();




Application.aspx
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Application.aspx.cs"
Inherits="ClientScripting_Sys_Application" Title="init Event和load Event和unload Event" %>



























onclick="listComponents()" />








运行结果
1、页面加载
弹出框,信息:ApplicationLoad
是否是部分刷新:false
最后一次触发load事件时创建的Component:Button1
最后一次触发load事件时创建的Component:Label1
弹出框,信息:Button1




2、鼠标点击、经过和离开“自定义Button(Button1)”或“自定义Button(Label1)”
有相应的提示




3、单击“列举所有Component”按钮
Component:0: id=Button1, type=Demo.CustomButton
Component:1: id=Label1, type=Demo.CustomButton




4、关闭浏览器
弹出框,信息:ApplicationUnload





CultureInfo.aspx(注:设置ScriptManager的EnableScriptGlobalization="True")
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="CultureInfo.aspx.cs"
Inherits="ClientScripting_Sys_CultureInfo" Title="CultureInfo" Culture="auto"
UICulture="auto" %>











中文 &nbsp; 英文
&nbsp; 阿尔巴尼亚语






















运行结果












区域名称:zh-CN









AMDesignator






上午













Calendar






[object Object]













DateSeparator






-













FirstDayOfWeek






0













CalendarWeekRule






0













FullDateTimePattern






yyyy’年’M’月’d’日’ H:mm:ss













LongDatePattern






yyyy’年’M’月’d’日’













LongTimePattern






H:mm:ss













MonthDayPattern






M’月’d’日’













PMDesignator






下午













RFC1123Pattern






ddd, dd MMM yyyy HH’:’mm’:’ss ’GMT’













ShortDatePattern






yyyy-M-d













ShortTimePattern






H:mm













SortableDateTimePattern






yyyy’-’MM’-’dd’T’HH’:’mm’:’ss













TimeSeparator






:













UniversalSortableDateTimePattern






yyyy’-’MM’-’dd HH’:’mm’:’ss’Z’













YearMonthPattern






yyyy’年’M’月’













AbbreviatedDayNames






日,一,二,三,四,五,六













ShortestDayNames






日,一,二,三,四,五,六













DayNames






星期日,星期一,星期二,星期三,星期四,星期五,星期六













AbbreviatedMonthNames






一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月,













MonthNames






一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月,













IsReadOnly






true













NativeCalendarName






公历













AbbreviatedMonthGenitiveNames






一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月,













MonthGenitiveNames






一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月,











dateTimeFormat示例:2007年6月22日 8:23:27






















格式化类型






格式化值



区域名称:zh-CN









CurrencyDecimalDigits






2













CurrencyDecimalSeparator






.













IsReadOnly






true













CurrencyGroupSizes






3













NumberGroupSizes






3













PercentGroupSizes






3













CurrencyGroupSeparator






,













CurrencySymbol




















NaNSymbol






非数字













CurrencyNegativePattern






2













NumberNegativePattern






1













PercentPositivePattern






1













PercentNegativePattern






1













NegativeInfinitySymbol






负无穷大













NegativeSign






-













NumberDecimalDigits






2













NumberDecimalSeparator






.













NumberGroupSeparator






,













CurrencyPositivePattern






0













PositiveInfinitySymbol






正无穷大













PositiveSign






+













PercentDecimalDigits






2













PercentDecimalSeparator






.













PercentGroupSeparator






,













PercentSymbol






%













PerMilleSymbol




















NativeDigits






0,1,2,3,4,5,6,7,8,9













DigitSubstitution






1











numberFormat示例:¥99.98



StringBuilder.aspx
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="StringBuilder.aspx.cs"
Inherits="ClientScripting_Sys_StringBuilder" Title="StringBuilder" %>














运行结果
StringBuilder:aaa
StringBuilder:aaabbb
StringBuilder:aaabbbccc




StringBuilder:aaaxxxbbbxxxccc
xxx




StringBuilder:
StringBuilder:true

作者:webabcd

[源码下载]













































添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.