asp.net AJAX register class

  • 2020-05-07 19:29:59
  • OfStack

1, register the namespace

Type.registerNamespace("wallis");

Just add wallis to window and you can use the namespace directly anywhere (window is global and can be omitted when used)

2, registration

wallis.Animal.registerClass("wallis.Animal");

It can be found in MicrosoftAjax.js
Type.prototype.registerClass = function Type$registerClass(typeName, baseType, interfaceTypes)
Here, Type points to an Funtion object, wallis.Animal, which is created with a prototype method, registerClass, which means that the ASP.NET AJAX client framework maintains an internal object that contains all the classes registered with the framework. This allows the user to perform a run-time class reflection query, which is similar to the class reflection query in.NET. This also means that each class registered with the ASP.NET AJAX client framework retains its corresponding metadata information, such as the type name, in an internal domain such as _typeName. So the user can perform the runtime object reflection.

With JavaScript alone, you don't need to register, but you just can't use some of AJAX's mechanisms.

Related articles: