📄 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" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="Server">
<Scripts>
<asp:ScriptReference Path="~/ClientScripting/Sys/CustomButton.js" />
</Scripts>
</asp:ScriptManagerProxy>
<script type="text/javascript">
Sys.Application.add_init(applicationInitHandler);
function applicationInitHandler()
{
// Sys.Component.create()
$create
(
Demo.CustomButton,
{text: '自定义Button(Button1)'},
{click: doClick, hover: doHover, unhover: doUnhover},
null,
$get('Button1')
);
$create
(
Demo.CustomButton,
{text: '自定义Button(Label1)'},
{click: doClick, hover: doHover, unhover: doUnhover},
null,
$get('Label1')
);
}
function doClick(sender, e)
{
Sys.Debug.trace("鼠标点击" + sender.get_id());
}
function doHover(sender, e)
{
Sys.Debug.trace("鼠标经过" + sender.get_id());
}
function doUnhover(sender, e)
{
Sys.Debug.trace("鼠标离开" + sender.get_id());
}
Sys.Application.add_load(applicationLoadHandler);
function applicationLoadHandler()
{
alert("ApplicationLoad");
}
Sys.Application.add_unload(applicationUnloadHandler);
function applicationUnloadHandler()
{
alert('ApplicationUnload');
}
function pageLoad()
{
// Sys.Application.findComponent() - 根据id查找Component
// Sys.Application.findComponent(id, parent) - parent可选
alert($find('Button1').get_id());
}
</script>
<script type="text/javascript">
function listComponents()
{
// getComponents() - 获得所有Component(数组)
var c = Sys.Application.getComponents();
for (var i=0; i<c.length; i++)
{
var id = c[i].get_id();
var type = Object.getTypeName(c[i]);
Sys.Debug.trace('Component:' + i + ': id=' + id + ', type=' + type);
}
}
</script>
<p>
<button type="button" id="Button1">
</button>
<span id="Label1"></span>
</p>
<p>
<input type="button" id="Button2" value="列举所有Component" onclick="listComponents()" />
</p>
<p>
<textarea id="TraceConsole" style="width: 500px; height: 400px;"></textarea>
</p>
</asp:Content>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -