string.aspx
来自「ajax实例,可以了解ajax的原理」· ASPX 代码 · 共 64 行
ASPX
64 行
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="String.aspx.cs"
Inherits="ClientScripting_TypeExtensions_String" Title="String Type Extensions" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script type="text/javascript">
var a = " abc ";
// 同 C#
document.write(a.startsWith("a"));
document.write(" ");
document.write(a.endsWith("c"));
document.write("<br />");
a = a.trimStart();
document.write(a.startsWith("a"));
document.write("<br />");
a = a.trimEnd();
document.write(a.endsWith("c"));
document.write("<br />");
a = " " + a + " ";
a = a.trim();
document.write(a.startsWith("a"));
document.write(" ");
document.write(a.endsWith("c"));
document.write("<br />");
var user =
{
Name: "webabcd",
Birthday: new Date(1980, 2, 14)
};
// String.localeFormat();
document.write(String.format("Name:{0},Birthday:{1:yyyy-MM-dd}", user.Name, user.Birthday));
document.write("<br />");
// 自定义格式化的实现
Type.registerNamespace('Demo');
Demo.CustomFormattedString = function()
{
}
Demo.CustomFormattedString.prototype =
{
// 实现toFormattedString方法,从而实现自定义格式化
toFormattedString: function(format)
{
return "自定义格式化:" + format;
}
}
Demo.CustomFormattedString.registerClass('Demo.CustomFormattedString');
document.write(String.format("{0:测试信息}", new Demo.CustomFormattedString()));
</script>
</asp:Content>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?