ASP optimization: Using data binding to achieve high-efficiency dynamic Web pages

Source: Internet
Author: User

Data binding is not a new concept, IE 4.0 has given it a lot of support. However, data binding has not received the attention it deserves, and many developers seem more willing to use server script. In reality, however, data binding is more efficient in terms of the code implementation of dynamic Web pages or in the productivity of Dynamic Web pages.

This article will introduce the architecture of data binding, how it works and how it is implemented, and finally make comparisons and conclusions between the two methods in terms of programming workload and Web page efficiency. 

First let's look at a simple example. A Web page shows the current inventory situation of the warehouse, the user can choose the sort of data by themselves: by the name of the goods, prices, inventory and other orders. Using server-side technologies, such as CGI, ISAPI, or ASP, if the user needs n sorting, the application script must submit at least n data requests to the server. For the same content of data, just because of the different display mode, it is necessary to do multiple database operations, consuming a lot of network bandwidth.  

Another common example is that when large amounts of data need to be paginated, each page of paging needs to reconnect to the server, submit the query request, and then locate the data.  For these similar issues, data binding provides an efficient solution.  

     The architecture and workings of data binding   the
Data binding architecture consists of four components: the data source object object), data consumers, and two proxies (Binding Agent and Table Reptition Agent). The data source object provides data to the Web page, and the data display object is the HTML element that displays the data, and the agent is used to ensure that the first two work synchronously. Figure 1 shows how the four pieces work together.  

1, the data source object is responsible for communicating with the background database server, and the data returned by DB server is cached in a collection as a local cache. Thereafter, any operations on this dataset, such as sorting, filtering, taking a subset, etc., are performed in the local cache, and the agent is responsible for communication and synchronization between the data source and the HTML elements that display the data.  


Figure 1

  

Shanghai men's Hospital program tips for readers, this way of working with data binding makes it possible for program developers to minimize the amount of script programming by simply using extended HTML and pluggable data source objects. Compared with the traditional server-side script-generated Web page, the data can be downloaded to the client once, and no additional server requests are required for any operation on the data, thus saving network bandwidth and increasing download speed.

implementation of data binding
This section describes each of its components and their implementation, based on the architecture of the data binding.

   1. DataSource Objects (data source object)

The first step in implementing data binding is to determine the data that the page will display, select a suitable Data source object (DSO), and then reference the DSO in the Web page. The flexibility of data binding first manifests itself in supporting a variety of Dso,ie 4.0 and later versions that support the following DSO types:

Tabular Data Control (TDC): This is a simple DSO that provides access to formatted text files. In other words, the data source provided by the TDC is a text file formatted with the specified delimiter.

Remote data Service (RDS): The predecessor of RDS is ADC (Access data Control). RDS communicates with the database through OLE-DB or ODBC to obtain data.

JDBC DataSource Applet: It differs from RDS in that the database connection uses JDBC.

XML data Source: Extensible Markup Language XML uses a standard way to describe and exchange structured data; XML is described in an open, text-based format and transmitted through a standard HTTP protocol. The nature of XML itself determines that it is inherently a flexible and powerful DSO. IE4.0 uses Java applets to implement XML dso;ie5.0 support data Island, the user can directly use the <XML> tag defined as the DSO.

MSHTML Data Source: In addition to using external controls as DSO, developers can define datasets in HTML documents and use the MSHTML itself as a data source.

Custom Type DSO: In addition to the above well-defined five types of Dso,ie also support user-defined type of DSO, as long as the DSO follows the IE 4/mshtml Data Binding interface can be.

DSO can be specified at design time, and can be dynamically added, modified, and deleted at run time.

2. Data display object supporting data binding (Consumer)

The bindable HTML elements are divided into two main categories: single-valued objects (single-valued Consumer) and Table objects (tabular Consumer). A single-valued object displays a field of the current record provided by DSO, and each row element in the Table object corresponds to a different field in one record, and it repeats each record in the dataset as a template. Data display objects can be bound to DSO at design time or dynamically at run time.

The dynamic nature of the DSO and data consumer allows the existing element bindings to be modified, and the DHTML Object Model (DHTML objects Modle) also supports the runtime to dynamically add data-binding elements and data source objects. Therefore, the data can be downloaded asynchronously to the client. This feature allows developers to reduce the initial download time for Web content and to display the contents of multiple different datasets on a single page, resulting in high-quality service for interactive users.

The HTML elements that support data binding include: A, Applet, Button, Div, Frame, Iframe, IMG, Input (including checkboxes, Hidden, Label, Password, Radio, text, etc.), Label, Marquee, Select, span, and textarea. where A, button, Div, IMG, Frame, Iframe, lable, marquee, and span support read-only data binding, while input (except Button type), Select, Textarea, The object and Applet elements support the update functionality of the data being bound.

3. Operations supported by data binding

For read-only data consumer, data binding supports the operation of displaying the datasets provided by DSO. Specific features include:

Dynamically add and modify the bound elements and DSO, such as changing the displayed data fields, filtering and sorting the data set, etc.

Dynamically change the way datasets are displayed, data can be displayed in HTML format, or in simple text format.

Dynamically control the number of displayed data to dynamically change the number of records that are contained on each page when paging is displayed.&NBSP; the

support for the update feature of data consumer not only supports the above features, but also supports record additions, modifications, and deletions. That is, the addition, modification, and deletion of the data on the interactive page will affect the data set to which the element displaying the data is bound. To facilitate the control of datasets, data binding allows developers to use all the methods and properties provided by ADO (Active data Objects) to maintain the data set provided by the DSO, including inserts, Update, delete, and navigation operations. &NBSP; a very important question in the data binding of

is that it must be clear What data does the consumer do that affect only the data in the local cache, or has it really changed the backend database (which is related to the type of DSO)? The TDC, XML data source, and MSHTML data source support only the changes in the cache, and do not support the submission of the changed cache data to the backend database to which the data source is connected. Both the RDS and JDBC DataSource applets support the ability to modify the backend database. &NBSP;

comparison and conclusions &NBSP; As you can see from table 1, data binding generates a significantly higher productivity relative to server-side scripting. However, using this method to the programmer's requirements is high, need a deep understanding of the data binding to give full play to its good characteristics. The complexity of the work is the cost of high efficiency, in the application, the developer should be based on the specific needs and actual situation, choose the appropriate method or combination of the two, in order to achieve the highest performance and price ratio. &NBSP;

Table 1

Compare items

Data binding

Server-side scripting

Web Productivity

Data download

Synchronous/Asynchronous

Synchronous

Filter or sort the data

Only one connection is established

n Operations need to establish N-Times connection

Pagination Display

Only one connection is established

New connection and location data required for each page turn

Direct database modification via data consumer

Support, and no programming required

Supported, but requires programming

Conclusion

Significantly higher download speeds, faster interaction with users, and high quality service

Download speed and interaction speed are inferior to data binding method

Programming productivity

Programming flexibility

High

High

Programming effort

Less

Many

Programming complexity

High

Low

Conclusion

Less programming effort, flexible use. But requires programmers to be familiar with the special methods and properties supported by DSO and data consumer, which is more complex than server-side scripting

Although the programming workload is large, but the use of flexible and simple, just familiar with the general database operation of the programmer can be competent

ASP optimization: Using data binding to achieve high-efficiency dynamic Web pages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.