In Internet Explorer on Windows, you can embed ActiveX controls in the page by using the <object/> element. To do this, you need to know the class ID of the ActiveX control you wish to embed (this informationncan be gleaned using the OLE/COM Object Viewer) and insert it as the classid attribute:<object classid=”activex_class_id”id=”ActiveXControl”></object>
Not all ActiveX controls behave properly when embedded in a Web page. Indeed,some of them trigger security warnings in Internet Explorer and possibly in software such as antivirus programs. However, a few ActiveX controls were designed to work appropriately and safely in Web pages. One such component is the tabular data control.
Specifically, the tabular data control allows you to use a flat text file as if it were a database table. You tell the control what the value delimiter character is,and it parses the text file into a series of rows and values.
To create a tabular data control on a page, you must use the class ID “CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83” (retrieved using the OLE/COM Object Viewer) and give the object an ID:
Next,you must specify the DataURL parameter, which indicates where the text file is located (this can be either a relative or complete URL), and the FieldDelim parameter, which indicates what the delimiter is between two values in the same row (most often this is a comma):
Lastly,if the file in question uses the first row as headers, you should set the UseHeader parameter to true,which doesn’t include the first row in the data values and also enables you to reference columns by name as well as position:
This code says to load the tabular data control with the data in Names.txt that has a field delimiter of “,” and use the headers as a key for each column.
Here’s a sample Names.txt file:
The first column is named first_name, and the second column is named last_name. On each row, commas, as indicated by using the FieldDelim parameter, separate the values.
The page’s load event does not fire until the tabular data control has fully loaded its data, so it’s safe to use the onload event handler to determine when the data is available.At that point, you retrieve the recordset created by accessing the recordset property of the control:
This code creates a global variable named oDataset that points to the recordset containing all the data.
You can iterate through the recordset by using the moveFirst(), moveLast(), moveNext(), and movePrevious() methods in combination with the EOF (end of file) and BOF (beginning of file) markers. For example, here’s a basic code outline to iterate through the recordset starting from the first record and ending with the last:
The first step in the previous code is to set the recordset to the first record.The while loop then tests EOF, which is true when the end of the file has been reached.Inside of the loop is where the data processing occurs before moving on to the next record.
It’s also possible to move backwards through the recordset using the opposite methods:
This code starts from the last record and works its way back to the first. The BOF property is equal to true when you reach the beginning of the file.
To get at the data,use the fields() method of the recordset with the column name (either first_name or last_name in the previous example) or the position of the column, starting at 0, in the table. This method returns an object representing the field that has a value property with the actual value. So to display the first name for each person in Names.txt, the following code can be used:
You could also use first_name instead of 0:
In this way, you can move through the recordset and get all the data you need.
The tabular data control is a useful component if you have the luxury of developing only for Internet Explorer on Windows. It has a great many uses for it, many more than can be discussed in this context. Its tie to both Internet Explorer as a browser and Windows as a platform has, however, greatly inhibited its use and adoption in Web development. Presently, such solutions are best suited for Intranet applications where the user base can be kept to those using IE on Windows exclusively.
Java Script Related Tutorials
|Adv Java Tutorial||Core Java Tutorial|
|Java-Springs Tutorial||Java Servlets Tutorial|
|EJB(Enterprise JavaBeans) Tutorial||JavaServer Faces (JSF) Tutorial|
|Java Swing Tutorial||Java Tutorial|
|JavaMail API Tutorial||Java 8 Tutorial|
|Java XML Tutorial||Java Bean Utils Tutorial|
|The Java Debugger (JDB) Tutorial||Java.math Package Tutorial|
Java Script Related Interview Questions
|Java Script Interview Questions||Adv Java Interview Questions|
|Core Java Interview Questions||Java-Springs Interview Questions|
|Java Servlets Interview Questions||EJB(Enterprise JavaBeans) Interview Questions|
|JavaServer Faces (JSF) Interview Questions||Java Swing Interview Questions|
|Java 8 Interview Questions||Java XML Interview Questions|
|JavaFX Interview Questions||The Java Debugger (JDB) Interview Questions|
Java Script Related Practice Tests
|Java Script Practice Tests||Adv Java Practice Tests|
|Core Java Practice Tests||Java-Springs Practice Tests|
|Java Servlets Practice Tests||EJB(Enterprise JavaBeans) Practice Tests|
|JavaServer Faces (JSF) Practice Tests||Java 8 Practice Tests|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.