在我的网页源代码中我有:
Sys.Application.add_init(function() {
$create(Sys.UI._Timer, {"enabled":true,"interval":300000,"uniqueID":"timerMain"}, null, null, $get("timerMain"));
});
什么是 Sys.UI._Timer?它是服务器端的 .Net 类吗?
最佳答案
Sys.UI._Timer
是一个类似于 System.Web.UI.Timer
的类服务器控件,但在客户端(使用 JS)运行,它使用 AJAX 客户端库创建计时器控件。该类的默认构造函数定义如下所示:
Sys.UI._Timer = function Sys$UI$_Timer(element) {
Sys.UI._Timer.initializeBase(this,[element]);
this._interval = 60000; // Interval property, measured in milliseconds
this._enabled = true; // Enabled property
this._uniqueID = null; // UniqueID property
// client-side only properties
this._postbackPending = false;
this._raiseTickDelegate = null;
this._endRequestHandlerDelegate = null;
this._timer = null;
this._pageRequestManager = null;
}
请注意 $create
是 Sys.Component.create
的简写静态方法,它创建(并初始化)一个组件并将指定类型作为参数(在本例中为 Sys.UI._Timer
)。您要设置到组件属性中的属性值必须以 JSON 格式提供,并且属性名称的用法不带下划线(因此 _interval
变为 interval
),使用此语法:
$create(type, { "propertyName": value, ... }, events, references, $get(elementName));
进一步阅读:
关于javascript - 如何在我的 JavaScript 中识别 Sys.UI._Timer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54681287/