Chapter 5. Data Binding and Validation
Data binding is the means by which data is bound to a control (that is, to an HTML page element), typically so that it can be displayed to the user. With data binding, for example, you can tie the contents of a text box to a label element, or transform the data a user enters into something else (for instance, HTML) and process it further. Very often, data binding is done using data from a database. Although this chapter covers the basics of Atlas data binding, Chapter 9 explains how to use Atlas to access data on the server.
The examples in the previous chapter did not use declarative code, which is one of the advantages of a framework like Atlas. Also, we found it necessary to use one or two hacks, such as using
setInterval() to keep two HTML elements in sync. In this chapter, you’ll learn xml-script, declarative markup that ships with current prerelease versions of Atlas.
Data binding links data and an HTML element for its visual representation. In ASP.NET, data binding is used with controls such as the
DetailsView although it is, of course, also possible to tie data to a bulleted list, for instance.
Atlas offers two approaches to data binding. One is programmatic, and the other uses a special kind of XML markup that Atlas interprets on the fly.
Using Code for Data Bindings
Doing data binding programmatically sounds more complicated than it actually is. Basically, you have to instantiate a class and then ...