Chapter 15. Binding and Validating Data

Data binding is the means by which a control (i.e., an HTML page element) is bound to data. Typically this is done so that it can be displayed to the user. For example, with data binding, 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 draws information from a database. This chapter covers the basics of ASP.NET AJAX data binding; Chapter 17 explains how to use ASP.NET AJAX to access data on the server.

The examples in Chapter 14 did not use declarative code to assign values to controls on the page, although the declarative coding model is one of the advantages of a framework like ASP.NET AJAX. Also, we found it necessary to use one or two hacks (or, put in more diplomatic terms, “less elegant” methods), such as using setInterval( ) to keep two HTML elements in sync. In this chapter, you’ll learn xml-script, a declarative markup that ships with the Futures release of ASP.NET AJAX.

Data Binding

Data binding links data with an HTML element which maintains it for visual representation. In ASP.NET, data binding is used with controls such as the GridView, FormView, and DetailsView. Though of course, it’s also possible to tie data to other objects, such as a bulleted list.

ASP.NET AJAX offers two approaches to data binding. One is programmatic, the other uses a unique kind of XML markup that ASP.NET AJAX interprets ...

Get Programming ASP.NET AJAX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.