Ms Ajax Lib-> String 类型扩展
来源:互联网 发布:安知玉如意txt 编辑:程序博客网 时间:2024/04/23 16:48
String 类型扩展
提供了基于 ECMAScript (JavaScript) String 对象的扩展.
命名空间: 无. 本扩展类型是全局型的不属于任意一命名空间。
继承: String
语法
var stringVar = new String();
成员扩展
名称
说明
String.endsWith 函数
确定 String 的末尾是否与指定的字符串匹配。
String.format 函数
将指定的 String 中的每个格式项替换为相应对象的值的文本等效项。
String.localeFormat 函数
将指定的 String 中的每个格式项替换为相应对象的值的文本等效项。区域设置将用于格式化时间和数字。
String.startsWith 函数
确定 String 开头是否与指定的字符串匹配。
String.trim 函数
从开始位置和末尾移除空白。
String.trimEnd 函数
从末尾移除空白。
String.trimStart 函数
从开始位置移除空白。
备注
String 扩展是Microsoft AJAX库的一部分。使JavaScript 的String与 .NET 程序结合的更密切.
更多关于 JavaScript 类的扩展类型的消息, 请参见 String Object in the JScript Language Reference.
下面的示例展示了如何 使用String.format
CS
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="ScriptManager1">
</asp:ScriptManager>
</form>
</body>
</html>
<script type="text/javascript">
Type.registerNamespace('Samples');
Samples.StringExample = function(){}
Samples.StringExample.prototype =
{
runExample: function()
{
var newStr = new String(" This is a string. ");
// Remove the white space at the beginning and end.
newStr.trim();
document.write(newStr,"</p>");
}
}
Samples.StringExample.registerClass('Samples.StringExample');
var myStringSample = new Samples.StringExample();
myStringSample.runExample();
</script>
VB
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="ScriptManager1">
</asp:ScriptManager>
</form>
</body>
</html>
<script type="text/javascript">
Type.registerNamespace('Samples');
Samples.StringExample = function(){}
Samples.StringExample.prototype =
{
runExample: function()
{
var newStr = new String(" This is a string. ");
// Remove the white space at the beginning and end.
newStr.trim();
document.write(newStr,"</p>");
}
}
Samples.StringExample.registerClass('Samples.StringExample');
var myStringSample = new Samples.StringExample();
myStringSample.runExample();
</script>
请参见
- String Object
- new Operator
- Ms Ajax Lib-> String 类型扩展
- Ms Ajax Lib-> Object 类型扩展
- Ms Ajax Lib-> $get 方法
- Ms Ajax Lib-> $addHandler方法
- Asp.net AJAX JavaScript 基本类型扩展(7)——String 类型及其扩展
- MsAjax Lib-> Boolean 类型扩展
- MsAjax Lib-> Date 类型扩展
- MsAjax Lib-> Error 类型扩展
- MsAjax Lib-> Number 类型扩展
- 【String类型】JavaScript中的原生对象以及Microsoft AJAX Library中的相关扩展
- Asp.net AJAX JavaScript 基本类型扩展
- MSAJAX对String 类型的扩展
- JavaScript string 字符串类型的扩展函数
- IE6下Ms Ajax Lib 调用Ajaxtoolkit时Common_InvalidPaddingUnit未定义的解决方法
- Javascript数组常用方法[包含MS AJAX.NET的prototype扩展方法]示例
- Microsoft AJAX Library Cheat Sheet (一)Array类型的扩展
- Microsoft AJAX Library(1)Array类型的扩展
- JavaScript string 字符串类型的扩展方法(搜集整理)
- (转)分享PHP入门的学习方法
- test
- Windows下的个人防火墙-网络数据包拦截技术概览
- ECMAScript 基础
- 嗯!
- Ms Ajax Lib-> String 类型扩展
- linux下抓包命令--tcpdump的使用
- ASP.NET 2.0页面 框架的几处变化
- asp.net技术文章
- C# Cookie操作
- simpleXML用法简介2——获取某个元素的属性值
- 聚焦“我要地图”:API大赛火爆进行中
- YAWL初探
- PasswordRecovery控件感悟