Autodesk 15606-011408-9300 Developer Guide - Page 127
Creating the Report Scripts
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 127 highlights
Creating the Report Scripts Next we'll create the three ASP files getpoint.asp, showform.asp, and insert.asp. The first file, getpoint.asp, creates a small browser window and then calls a second file, showform.asp, passing along the coordinate values it received from Autodesk MapGuide: window.close( ); var loc = "showform.asp?LAT=" + "" + "&LON=" + ""; win = window.open(loc,"ShowFormWin", "width=300,height=170,dependent=yes,resizable=yes"); win.focus(); Note that getpoint.asp consists of a single element containing a block of JavaScript code; because the file doesn't display any text, no other HTML tags are needed. Let's look at the code line by line. When getpoint.asp is first called it uses a default browser window similar to the one in the previous example. The first line of code closes that window. Note Because the browser parses the entire block before running the first line of code, we can safely close the window, knowing our script will continue to run. Be aware, however, that this strategy will get you into trouble if your file contains function calls or other multiple blocks. See your JavaScript documentation for more information. The next line constructs a URL and assigns it to a variable called loc. Note that the line is a mix of both JavaScript and ASP code. The ASP code is processed first, on the server. Then the line is sent to the browser as standard JavaScript. Let's look at how it works. As you might recall from the previous example, ASP variables use the standard ASP script tags (), as well as an equal sign that tells ASP to substitute the actual value for the variable. In this case, the variables hold the values Request.Form("lat") and Request.Form("lon"), both of which refer to Request.Form, the ASP Request object's Form collection. The Request object is used by ASP to parse submitted data received from a client as part of a URL. Form is a collection representing HTML form parameters transmitted via the HTTP POST method; these parameters can be accessed from the collection by name. In this case, the collection has two members: the LAT and LON parameters that were posted to the file by the Autodesk MapGuide Viewer. After the ASP code is processed, a line similar to the following is sent to the browser: var loc = "showform.asp?LAT=" + "37.721" + "&LON=" + "-121.943"; Creating Report Scripts with ASP | 127