This article may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. To maintain the flow of the article, we've left these URLs in the text, but disabled the links.


MIND


GEEK

Robert Hess

GEEK In a frame-based version of an Active Server Pages (ASP) project, how do I pass around Request.QueryString to different modules? For example, how do I get the QueryString in abc.asp from another file called bde.asp?
GEEK The use of Request.QueryString is a server-side operation. The structure and contents of the frames within a <frameset> is a client-side feature, so there isn't any way for abc.asp to simply target a Request.QueryString to pull data out of bde.asp. Instead, you need to design your pages so that they pass the information between frames on the client prior to the ASP file being requested.
      There are many ways of doing this, but forms with hidden inputs are especially appropriate. Assuming that bde.asp is managing the login of the user, and abc.asp is managing a request for information, the server-side code for bde.asp might look something like this:


     <form name=userinfo>
     <input type=hidden name=username 
     value=<%=request.querystring("username")%>>
     </form>
Then when the user issues a request for information in abc.asp, the client-side code might look like:
 
     <form onsubmit="return validate();" ...>
     ...
     <input type=hidden name=username>
     </form>
     <script language=vbscript>
     function validate
           ...do whatever you want to do for validation
           ...now go grab the username from the other frame:
           document.myform.username.value = _
               window.parent.frames("login").document.myform.username.value
     end function
     </script>
This will "borrow" the form value from another frame and pass it along as a form value in the current frame, allowing your server-side code to get the login value.

GEEK What does the Win32® API function GetUserName assign as the user name if there are no individual user configurations on a system?
GEEK GetUserName will return the name of the currently logged in user. Under Windows® 95, it is not necessary to log in to the system, so in this case the function will return false.

GEEK What kind of non-Java code can I put into a script (see Figure 1) so that not only will the mouse rollover effect work (it already does), but a large area dedicated to displaying JPEGs will change at the same time? In other words, every time a mouseover occurs over the button, I want an image over the button to change as well as the button itself.
GEEK Changing two or more images on a mouseover event is easy. The mouseover event doesn't have to occur on the image you are trying to change; you can easily change any image on the page. And with just a little extra code, you can even change all of the images on the page in response to a single mouseover or mouseout.
      In your case, I'll assume that in addition to changing the image button to a highlight state on mouseover, you also want to do something like show a preview of the page or picture that will be brought up if you click the associated button. In such a case, you could easily modify your code to something like:


     function turnOn(imageName) {
       if (document.images) {
           document[imageName].src = eval(imageName + "on.src");
           document["preview"].src = eval(imageName + "preview.src");
       }
     }
 
     function turnOff(imageName) {
       if (document.images) {
           document[imageName].src = eval(imageName + "off.src");
           document["preview"].src = nopreview.src;
       }
     }

GEEK How can we perform ADO accesses to SQL Server™ databases written in Java? Supposedly, ADO for Java shipped with the Internet Client SDK, but we haven't been able to find it.
GEEK The recently announced Visual J++™ 6.0 includes support for ADO access. You can find more information about this at http://msdn.microsoft.com/visualj/ and http://msdn.microsoft.com/visualj/prodinfo/datasheet/

GEEK I would like to design and test ASP files locally under Windows 95. I have Microsoft Internet Explorer, FrontPage® Server, and the Personal Web Server, which came with FrontPage. Do I need to run Internet Information Server as well? If so, how?
GEEK If you are running Personal Web Server on your Windows 95 system, then you have everything you need to host ASP pages on your local Web site.
      The important thing to remember is that you need to open the pages via the HTTP transport, not the FILE transport. To see your local Web from your browser, just enter http://localhost in your address bar. The file this points to depends on the directories you specified when you installed Personal Web Server on your system.

GEEK I know you can read from and write to a one-line text box from ASP, but can you read from or write to a scrolling text box? Is reading from or writing to a memo field different than it is with a text field?
GEEK What's wrong with this?

    — [ TextArea.HTML ] ————————————————————
     <html>
     <body>
     <form action="textarea.asp" name=form onsubmit="return test();">
     <textarea name=textarea></textarea>
     <input type=submit>
     </form>
     <script>
     function test() {
         alert (document.form.textarea.value);
         return true;
     }
     </script>
     </body>
     </html>


 — [ TextArea.ASP ] ————————————————————
     <html>
     <body>
     <%=Request.QueryString("textarea")%>
     </body>
     </html>
It works fine for me.
      The main difference between memo and text fields (when talking about database field types) is that a text field is 256 characters, while a memo field is unlimited. Memos also usually can't be used in queries. Regarding server-side ASP processing, a memo field returned from a database query can only be read from the recordset object once. So if you had a memo field called, appropriately, memo, then

     <%=rs_item("memo")%>
     <%=rs_item("memo")%>
would return an error on the second attempt to display the memo. The correct way to do this is:

     <%memo = rs_item("memo")%>
     <%=memo%>
     <%=memo%>

GEEK A friend is using Microsoft Outlook 97. Whenever he sends mail to a recipient using a Unix server, the message loses its word wrap (the message appears to the recipient as one long line of text). Have you ever heard of this? Do you have any suggestions?
GEEK In my opinion, the real problem is with the client application displaying the mail on the Unix end, not with the application that sent it. If I were writing an email application, I'd figure that any text that scrolls off to the right of the display area would be unreadable, and since reading the message is the whole point of an email program (unlike a word processor, where the intent is usually to get the document ready for printing), it only makes sense to provide an option to automatically wrap text. That said, the chances are good that the application being used on Unix has this capability, and the user has turned it off (or doesn't know how to turn it on). Unix systems have been doing email longer than anything else, so the email programs available there are usually pretty good.
      Outlook 97 assumes that line wrapping will be done on the client, and that any hard carriage returns in the mail are there because that's where the author really wanted a line break. This works especially well from an "accessibility" standpoint. This means that the receiver can easily pump up the font size to increase readability if he is visually impaired; the message is far more legible than if carriage returns assuming 78-character line lengths were inserted by the sender.
      Have the Unix user look more closely at the email program and see if it has a setting for auto-wrapping. If not, look for another that does, or contact the author of the program and suggest this as a feature.
      To deal with this problem at the sender's side, you can check out: http://www.microsoft.com/office/dlsupport.htm/. This is a download location for a number of handy tools and add-ins for Microsoft Outlook. Look at the Internet Mail Enhancement Patch; installing this will add a "Wrap outgoing mail at..." option.

GEEK I am constantly using onmouseover and onmouseout events within one of my HTML pages to swap between different images. Since it can sometimes be slow, is there any way of preloading an image from JavaScript?
GEEK This code is preloading the images when it sets the .src attribute of the image array:


     for (i=0; i<count; i++) {
          item[i] = new Image;
          item[i].src = root + months[i] + year + "back" + type
     }
       Figure 2 shows this in action. Copy this file to your local machine. Start Internet Explorer and, from View | Internet Options | General, select Delete Files in the Temporary Internet Files section. This will clear out your cache. From the File menu, select Work Offline. And just to really clear things out, close down Internet Explorer (this will release any images that it might currently have in memory).
      Now double-click on the sample page from Figure 2. You should see the text of the page come up, but not the images. Move your mouse over several of the backissue listings and verify that no images appear. Now, move your mouse to the top of the screen to keep it from generating mouseover events. From the keyboard, hit Alt+F, then W, to turn off the Work Offline mode. Hit F5 to refresh the page. Notice in the status bar that several images are being downloaded.
      Next, hit Alt+F then W, to turn the Work Offline mode back on. Move your mouse over the backissue listings on the page. Notice that the image display on the right displays the appropriate MIND magazine covers, and very quickly as well.

GEEK I have created an .alx file that will contain two command buttons and two text entry boxes as an input form. One button will reset the form. I would like the other button to submit the contents of the two text entry boxes to my own address via email. How can I do this?
GEEK Assuming you have all the necessary messaging stuff installed on the server so that you can do this via a normal form, this should be relatively straightforward.
      Construct the form container within the HTML on the page, but where you would normally insert standard text boxes and such to accept user input, use <input type=hidden name=…> input elements. The .alx file will then define corresponding visual elements that the user will actually be interacting with. At form submission time, the OnSubmit event handler for the form will reach into the elements within the .alx file, pull out the current values, and populate the hidden form elements just prior to submission. Or each of the individual . alx elements could push their values out to their hidden twins any time they detect their values have changed.
      Note that .alx files are created for the HTML Layout Control designed for Internet Explorer 3.0; they were essentially a sneak preview of the positioning features of Dynamic HTML (DHTML). While there are some differences in actual functionality, you should be thinking about how you can convert this functionality to use DHTML instead of relying on the outdated HTML Layout Control.

GEEK I have a Microsoft Excel spreadsheet that is updated every n minutes with DDE. How can I get this information onto a Web page?
GEEK Figure 3 shows how you can get to a Microsoft Excel spreadsheet via ODBC and ASP. The method is straightforward, and works much the same as for accessing a Microsoft Access or SQL database. A key stumbling point is how to specify the "table" you want to query against and extract data from. At first blush, you might think this would be the same as the sheet name, but instead the table name is a reference to a named range of cells on the spreadsheet.
      So for Figure 3 to work, the following will need to be done first: Figure 3 assumes that c:\my documents\sample.xls has been created on the Web server; in addition, if you need to create the file someplace else, be sure to update the PATH and FILE variables appropriately. The ODBC drivers on your server needs to be installed properly, including the driver for .XLS files.
      In the sample spreadsheet, you need to:

  1. Enter some data.
  2. Select the range of cells you want to expose.
  3. From the menu, select Insert | Name | Define.
  4. Specify DataTable1 as the name.
  5. Make sure the top row of the named range contains the field names.
      It should then display the information from your Microsoft Excel spreadsheet.


From the May 1998 issue of Microsoft Interactive Developer.