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

Targeting Frames, Hidden Fields, Dropdown Menu Positioning, and Distilling Other Web Sites
Robert Hess
Q I want to be able to return fields from a Microsoft® Access database and display them by using a key in a listbox design-time control (DTC). I want these fields to be displayed in textboxes that can be altered using add, change, and delete. How do I link the listbox selections to textboxes on another page?

A I don't think that the issues involved here are specific to a DTC, and it's not important that the values are coming from fields in a Microsoft Access database. It sounds like you want to click on a listbox item in one page, and have values underlying that selection displayed in textboxes on another page.
      How you achieve this result will depend on the relationship between these two pages. If your site is frame-based, with the listbox displayed in one frame and the textboxes in another, you can manually set the textbox values during the onchange event, then access the text field of the other frame by popping it up through the parent object. The three HTML files in Figure 1 show how it's done.

Q I have a self-referential ASP form that uses the POST and Request.Form methods. It uses hidden fields to pass some of the data. The form works fine with Microsoft Internet Explorer 4.0, but fails in Internet Explorer 5.0. The problem is that the form does not get submitted when I'm running Internet Explorer 5.0. Instead, it triggers the ELSE command in my code, as if the hidden field was empty. How can this be? Does Internet Explorer 5.0 implement forms differently than Internet Explorer 4.0?

A I attempted to whittle down the sample code you sent to bare bones for simplicity (see Figure 2). Once I did so, this example appeared to work perfectly fine for me on both Internet Explorer 4.0 and Internet Explorer 5.0.
      One thing I should mention about the code in Figure 2 is that I don't recommend that you test for a null string in this fashion. I prefer to test for the size of the string instead and only after removing possible spaces that might be in it, so I would have coded the test as:
  
IF len(trim(Request.Form("job")))<=0 THEN
    TargetJob = "..whatever you want it to be in this case"
ELSE
    TargetJob = Request.Form("job")
END IF

Or perhaps this way:

  
TargetJob = Request.Form("job")
IF len(trim(TargetJob))<=0 THEN
    TargetJob = "..whatever you want it to be in this case"
END IF

Q My Web site uses dropdown menus. When a menu drops down over a SELECT listbox, the listbox always seems to move to the top of the z-order. I've tried the z-index style, but it does not work. The simple sample I created proves this point (see Figure 3). Am I dealing with a bug, or some other unusual problem that has a kludgy workaround? Nothing I've tried seems to work.

A This is a common issue with dropdown menus and other forms of layer positioning. An important thing to understand about implementing dropdown menus on a Web page is that there are several types of objects you can put in a page that will clip the menu when it is displayed. The select/listbox form items as well as <iframe> elements will be drawn on top of a dropdown menu, which is displayed using absolute positioning with a <div> element. It is not a bug in the browser that causes this; it's more of a complex interaction of parent/child windows and clipping regions. The best workaround is to design your pages so that all dropdown menus are far enough away from other boxes, frames, and so on, to prevent this clipping behavior. Another method I've seen is to hide the listboxes or other items when a dropdown is activated.
      When you go to the MSDN® Library (https://msdn.microsoft.com/library), the menu bar is displayed, but not the dropdown menus themselves because they would have gotten clipped by the frames that are displaying the tree structure and document contents.
      Like it or not, HTML and scripting is no substitute for full-featured application programming. While it may seem to you that with each version of the browser more and more complex capabilities are exposed, it will probably be a while before everything you can do in Visual Basic® or C++ can be accomplished with HTML and scripting.

Q I want to sniff out news stories from other Web sites, get the links to the articles, extract the headlines, and select the important news items so I can present the links to readers on my Web site like MSNâ„¢ and Yahoo do. I also want this to be fully automated.

A Selecting the hot news items is a value judgment, and computers really don't do a very good job of this.
      Extracting titles from a particular news link is a little easier. HTML and XML are well-suited to this task. Since they are tagged markup languages, it is easy to identify keywords, phrases, titles, and other information and extract them. For example, HTML has a <title> element, which is the perfect place for a news article to state its title. Plus, the markup format makes it easy for you to write code to grab this information. The reality, however, is that if you don't own the pages you are trying to sniff, you really can't make any assumptions about how the <title> element is going to be used on the pagesâ€"if it's used at all.
      For example, one news source might format their titles something like this:

  
<title>East County News: Your source for news in East County -
 Mayor resigns, Dog Catcher Takes Over</title>

This is a pretty sad use of the <title> element. You wouldn't want to display that entire title on your news summary page, but parsing out the fragment that you do want will be difficult. In addition, you will need special cases for each news source you reach into. Your code would also have to be on the lookout for changes in formatting, so you could quickly change your code in order to prevent garbled headlines.
      There are other methods you can use for parsing HTML and identifying the headlines, but most of these methods are also dependent upon the formatting of the Web page code itself. They are also extremely prone to breaking with changes in formatting.
      Most news Web sites rely on a manual process of submitting news articles in a way that allows them to be used by some form of semi-automated news summary page. Since they own the process of getting these stories, all they have to do is standardize the process that the reporter uses to create the title, summary, categories, and the text of the article.
      If you want to provide a news summary page that points to articles on other news-based sites you really need to involve people in the process. They would cull through the various news sources, find links to important articles, and add the URL, title, summary, category, and so on to your database.
      You could also subscribe to some form of news service that provides you with news stories and relevant information in a format that you could automatically categorize and summarize. For example, NewsEdge (https://www.newsedge.com) has been providing news reporting services of this nature for about a dozen years.

Q I'm trying to write an application that uses the WebBrowser Control to print HTML documents. Since I have several printers connected to the PC and want to be able to print on each of them, I am looking for a way to choose the printer programmatically. I didn't find a solution in the MSDN documentation or in any news group. I know the command to print is

  
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER

but I don't know how to select a specific printer other than the default printer. Since my application runs in batch mode, I cannot choose the printer interactively.

A Accessing the print capabilities of the browser is a limited functionality. The ExecWB option doesn't provide a robust enough interface to allow very fine control of the various options in the print dialog box of the application you are interfacing with (in this case, the browser).
      One option is to change the default printer programatically prior to calling the ExecWB function (and perhaps even prior to initializing the WebBrowser1 object). Just remember, such a task is not for the faint of heart. Knowledge Base article Q246772 describes how to change the default printer using C.
      Of course if you change the default at runtime, make sure that you restore the user's default setting after printing.

Q I have a file (default.htm) in which I defined three frames: toc, top, and main. I use hover buttons to open pages in the main frame, but they actually open the page in its own window. It's as if it is opening on top of the existing window. I specified

  
<param name="url" valuetype="parent.main.location.href" 
value="Technology.htm">

in the hover button's properties, but it does not help. However, if I refer to the page with a normal URL like

  
<a href="photos.htm">photos.htm</a>

photos.htm opens in the main frame. What am I doing wrong?

A The problem is that you are trying to set the target frame of the hover button incorrectly.
      The hover button is a Java-language class that is supplied with Microsoft FrontPage®. When you right-click on a hover button in FrontPage, you will be allowed to set the properties of the button via a special dialog. The Link To field allows you to set the Web page for the browser to navigate to when the user clicks on the button. In order to assign a target frame for this link to open in, you need to click the Browse button that's next to the Link To field. This will bring up a new dialog, which provides greater control over the actions of the hover button. Near the bottom-right of this dialog, you will see a Target Frame field with a <pencil> button next to it. When you click this button, you can select the target frame. The code that is then added to your page will look like

  
<param name="target" value="main">

which is probably just as easy to add to your code manually.

Q I have developed an online help manual using a very large XML data file and several XSL data files (see Figure 4). Because this file is so large, I would like to break it up into several files, one for each chapter. Is there a way to have my original XML file just import each chapter when needed?

A Unfortunately, at the present time XML doesn't support something like a #include of additional data. The W3C is working on a proposal for an XInclude which will support this, but it will be a while before it is implemented.
      In the meantime, there are other options. While they are not as clean as a pure XML approach, they will at least provide some relief. A simple option is to maintain an ASP page that is capable of gathering up the various XML files and sending them back to the client browser.
      A more complex, and browser-dependent way is to use XSL to manage the data inclusion.
      As luck would have it, Chris Lovett recently wrote an article for MSDN Online Voices in which he details how he solved a very similar problem. You can find this article at https://msdn.microsoft.com/voices/xml05292000.asp.

Q How can I activate my own application in response to a click on a file link in the browser? Does Internet Explorer have a registry entry that tells it to activate a certain application before downloading a file?

A Internet Explorer uses the settings found in the system registry for determining how to deal with incoming files. There are a number of settings stored in the registry that deal with this information. The easiest way to tailor the setting is to right-click on a file you want to open, and select the Open With option. From the dialog that comes up, select the application that you want to use for opening that type of file, or if you don't see your application in the list, select Other. Then, once the application is selected, make sure the "Always use this program to open these files" option is selected, and click OK. This will create the appropriate association with this file for future use.

Robert Hess is currently the host of "The MSDN Show" and is a regular contributor to various areas of MSDN. Send e-mail to webqa@microsoft.com.

From the September 2000 issue of MSDN Magazine.