Recommended: Use Response attribute in ASP-- contenttype I encountered such a problem when using ASP to create web pages for a certain unit. In the previous MIS system of the unit, some Word files were saved in the database in the form of byte streams. Now the user asked me to use ASP to take out these Word file data from the database and display them in the web page.
Data Binding is not a new concept, and IE 4.0 has already provided rich support for it. However, data binding is not valued as it deserves, and many developers seem to be more willing to use server-side scripting methods. However, in fact, data binding is more efficient than the latter, both in terms of the code implementation of dynamic web pages and in terms of the work efficiency of dynamic web pages.
This article will introduce the architecture, working principle and implementation method of data binding, and finally make comparisons and conclusions on the programming workload and web page efficiency of these two methods.
First let's look at a simple example. A certain web page displays the current inventory status of the warehouse. Users can choose the sorting method of the data by themselves: sort by the name, price, inventory quantity, etc. of the goods. Using server-side technologies, such as CGI, ISAPI, or ASP and other middleware, if users need N sorting methods, the application script must submit at least N data requests to the server. For data with the same content, multiple database operations are required just because of the different display methods, which consumes a lot of network bandwidth.
Another common example is that when a large amount of data needs to be displayed paging, each time you turn the page, you need to re-establish a connection to the server, submit a query request, and then locate the data. Data binding provides efficient solutions to these similar problems.
Data binding architecture and working principle
The data binding architecture includes four components: a data source object, a data display object, and two agents (Binding Agent and Table Reptition Agent). The data source object provides data to the web page. The data display object is the HTML element that displays the data, and the proxy is used to ensure the working synchronization of the first two. Figure 1 shows the principle of the four parts working together.
As shown in Figure 1, the data source object is responsible for communicating with the background database server and caches the data returned by the DB Server in the local cache as a collection. After that, any operations done on this dataset, such as sorting, filtering, subsetting, etc., are performed in the local cache, and the proxy is responsible for communication and synchronization between the data source and the HTML elements that display the data.
Figure 1
This way of data binding works allows program developers to minimize the programming volume of scripts by using extended HTML and insertable data source objects. Compared with web pages generated by traditional server-side scripts, after data is downloaded to the client once, no additional server request is required for any operations done on the data, thus saving network bandwidth and improving download speed.
Implementation of data binding
This section will introduce its components and implementations according to the architecture of data binding.
1. Data Source Object
The first step in realizing data binding is: determine the data to be displayed on the web page, select a suitable data source object (DSO), and then refer to the DSO in the web page. The flexibility of data binding is first reflected in supporting multiple DSOs. IE 4.0 and above supports the following DSO types:
●Tabular Data Control (TDC): This is a simple DSO that provides access to formatted text files. That is, the data source provided by TDC is a text file formatted with a 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: The difference between it and RDS is that the database connection uses JDBC.
●XML Data Source: Extended markup language XML uses standard methods to describe and exchange structured data; XML data is described in an open, text-based format and is transmitted through the standard HTTP protocol. The characteristics of XML itself determine that it is inherently a flexible and powerful DSO. IE4.0 uses JAVA APPLET to implement XML DSO; IE5.0 supports Data Island, and users can directly use the <XML> tag to define data as DSO.
●MSHTML Data Source: In addition to using external controls as DSO, developers can also define data sets in HTML documents and use MSHTML itself as the data source.
●Custom type DSO: In addition to the five types of DSOs clearly defined above, IE also supports user-defined types of DSOs, as long as the DSO follows IE 4/MSHTML Data Binding Interface.
DSO can be specified at design time or can be added, modified and deleted dynamically at runtime.
2. Data Consumer that supports data binding
The binding HTML elements are divided into two categories: Single-valued Consumer and Tabular Consumer. A single-value object displays a field of the current record provided by DSO, while each row element in the table object corresponds to a different field in a record, and uses this as a template to repeatedly display each record in the dataset. The data display object can be bound to DSO at design time or dynamically at runtime.
The dynamic characteristics of DSO and Data Consumer enable existing element bindings to be modified; not only that, the DHTML Object Model also supports dynamic addition of data binding elements and data source objects at runtime, so data can be downloaded to the client in an asynchronous manner. This feature allows developers to reduce the initial download time of web page content and display content from multiple different data sets on a page, thereby enabling interactive users to obtain high-quality services.
HTML elements that support data binding include: A, Applet, Button, Div, Frame, Iframe, Img, Input (including Checkbox, Hidden, Label, Password, Radio, Text, etc.), Label, Marquee, Select, Span and Textarea. Among them, A, Button, Div, Img, Frame, Iframe, Lable, Marquee and span support read-only data binding; while Input (except Button type), Select, Textarea, Object and Applet elements support the Update function of bound data.
3. Operations supported by data binding
Share: How to use ASP programs to determine whether there are files on a disk The following is the quoted content: <%dim objfolderdim objfsodim j set fso=server.CreateObject(scripting.filesystemobject&q
2 pages in total Previous page 12 Next page