Besides the direct JavaScript programming mode, ASP.NET AJAX
provides another way to instantiate client-side types—declarative programming mode. Please take notice that to use
the xml-script feature you must download the Futures CTP package
from the Microsoft Ajax website and add a reference to the PreviewScript.js
file contained in the Microsoft.Web.Preview assembly. For more detailed study
on the declarative programming model under the lately ASP.NET AJAX 1.0, please
refer to Alessandro Gallo's excellent series of tutorial on xml-script
declarative programming from here.
But note that this tutorial has just scratched the surface of xml-script
programming, so to grasp this approach of programming you have to study almost
every detail of the excellent example—TaskList
Microsoft has provided and even analyzed the xml-script grammar resolver inside
file PreviewScript.js.
Therefore, we merely outline the basic steps when using the declarative
mode, while let the code snippet anywhere in this series tell you the practical
usage.
1.
Design your web pages as usual—define
the HTML elements.
2.
Create the MS AJAX client-side controls associated with these HTML
elements.
3.
Manipulate these MS AJAX client-side controls to control the
corresponding HTML elements indirectly.
To make declarative programming much easier, MS AJAX has not
only introduced many client-side controls (such as Label, Button, InputControl,
TextBox, Image, HyperLink, CheckBox, Select, ItemView, ListView, etc.), but
also created a few advanced concepts (such as action, behavior, data binding,
etc.).
In my opinion, the declarative mode comes into practice at
least due to two important things: 1. to simplify the pure JavaScript
programming by configuring the needed xml elements or tags and 2. to adapt to
the future programming mode—separating
the design from the implementation to facilitate development, as well as
simplify the course of maintenance, updating, internalization, third-party
development, compilation, and deployment, etc. While there exists these strong
points with the xml-script declarative mode, from another point of view, this
kind of script based on the XML schema makes debugging much more difficult. When
I debug the samples I have to resort to the source code of the framework to
find the bugs with little help from the error messages displayed. In some
degree, this means you have to be familiar with the inner workings of the framework—too difficult for common programmers. Moreover,
now there does not exist debugging tools to step into the declarative part of
xml.