Based on a study of the Microsoft ASP.net Ajax 1.0 Framework, this article continues to discuss how to create a asp.net Ajax non-visual client component derived from the base class Sys.Component and to demonstrate its use in Web pages.
First, Introduction
In this article, we'll discuss how to create a asp.net Ajax non-visual client component that derives from the base class Sys.Component and will demonstrate its use in Web pages.
Specifically, you will learn how to achieve:
Use prototype design mode to define a class of non-visual components in JavaScript.
Registers a non-visual component as a class derived from the base class component.
Initializes the base class-component of the Non-visual component and invokes its method.
Create a property that can fire a change notification.
Create a complete Demo.Timer, non visual component.
This component is used in a Web page and is bound to its events.
Note that in addition to the methods described in this article, which derive from component, there are two other types of extended basic component functionality that are built into the client components in the ASP.net AJAX 1.0 framework asp.net Ajax client component objects: behavior derived from Sys.UI.Behavior and control derived from Sys.UI.Control. The following table summarizes the differences between Component,behavior and control.
In addition, to run the examples in this article, you need to have the following conditions:
a test site;
Install the Microsoft ASP.net AJAX 1.0 framework, no longer repeat here.
Second, the basic functions of non-visual client components
A asp.net ajax the Non-visual client component encapsulates the JavaScript code that will be used in the application. A typical example of a non-visual component is a timer component that fires events at a certain time.
By deriving from the component base class, your custom component can automatically inherit many of these features, including:
A cross-browser model-for managing the processors bound to client object events.
Automatically registers the component in the client application as a Deallocated object that implements the Sys.IDisposable interface.
Fires a notification event when a property changes.
Implementing a batch of component property settings is more efficient than handling all the logic with a single property's get and set accessors (in terms of script size and processing time).
Overload the Sys.UI.Control.initialize method to initialize all properties and event listeners.