简体   繁体   中英

How do I identify Sys.UI._Timer in my JavaScript?

In my web page source code I have:

Sys.Application.add_init(function() {
    $create(Sys.UI._Timer, {"enabled":true,"interval":300000,"uniqueID":"timerMain"}, null, null, $get("timerMain"));
});

What is Sys.UI._Timer ? Is it a .Net class on the server side?

Sys.UI._Timer is a class which resembles System.Web.UI.Timer server control but runs in client-side (using JS) which creates timer control using AJAX client library. The default constructor definition of that class is shown below:

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;
}

Note that $create is shorthand from Sys.Component.create static method, which creates (and also initializes) a component with specified type as parameter (in this case, Sys.UI._Timer ). The property values you want to set into component properties must be provided in JSON format and property names usage are given without underscores (hence _interval becomes just interval ), using this syntax:

$create(type, { "propertyName": value, ... }, events, references, $get(elementName));

Further reading:

Sys.UI._Timer - ASP.NET AJAX Client Library

Sys.UI Namespace - MS Docs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM