Scripting a Data Access Page: a Simple Example - Saving and Displaying the Data Access Page
(Page 4 of 4 )
Saving the file
You need to save the page before displaying on a browser. Now from the file menu you can choose to save, and it will normally get saved to the default directory, C:My Documents. If you want it saved to the web server, you may place it on the web server by saving it to the C:Inetpub/wwwroot, or to a virtual directory of your choice.

You may however get the following message. Presently the data source is referenced by its absolute path. If you want to connect to it through the network, you may have to give the UNC path (ServerSharefile) name. Just click OK and proceed. It gets saved to the folder you chose. In the present tutorial it is saved to the virtual root of the IIS Server.

Displaying the file and testing the script
Since the data access page is on the website, it can be displayed by browsing the file with the IE. At first you will get this warning message shown in this window.

When you click OK to the above you will get another warning about access as shown in the next picture.

When you click OK to the above also, then you will see your data access page as shown here.

It opens with the first record as shown. You can move to the other records by using the navigation buttons provided. We added the script to Command1 button with the caption 'London?'. Since we are on a record whose city field shows 'London' we can click the button. You may see a couple of message boxes if you have not commented out the MsgBox statements in the code, but you will finally see the page shown in the next picture.

Now you may move out of Customers 1 and move to some other record where the city is not 'London,' such as the one shown in the next picture, and click on the command button. You will see the following window, which shows that the script is indeed working.

Summary
There are two requirements for successful scripting of a data access page, understanding the Microsoft Script Editor and the JavaScript object model. ECMA syntax is used in the code, which facilitates a standards-based approach to scripting. The script on this page is very simple, but one look at the Client Objects available for scripting shows an enormous potential for intricate scripting.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |