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 I have a question about the wonderful (but frustrating) Summary Information Component for ASP. When I use it, can I specify the order in which the files are listed? If so, how can I do this? By default, they are listed by file name, but I would prefer to order the entries by date or time.
GEEK The Summary Information Component (ASPSum-Info, which is included in the Microsoft Internet Information Server Resource Kit, available from Microsoft® Press), doesn't allow you to specify an alternate sort type for enumerating files. You would have to prepare your own independent list of files based on your own sort criteria, then pass the files one at a time to ASPSumInfo to extract details in the manner you want.

GEEK It seems like Internet Information Server (IIS) doesn't accommodate browsers that don't handle cookies or cases where users have set their browser to not accept cookies. The only solution is to use the Cookie Munger. Why can't there be an option within IIS that takes care of this? For example, if it finds that the user won't accept cookies, write the cookie to a temporary database and use the information from there. Do I have to accept the use of cookies?
GEEK One problem with the Web and HTTP is that there is no notion of a session built into it, meaning that there isn't any (easy) way for the server to keep track of the start-to-finish travels of the user without client-side cookies or some method of server-side tracking based on data passed via URL. The closest thing the HTTP headers provide for this is that one of the header elements identifies what URL the user came from.

    Client-side cookies provide a very clean and easy way to fix this problem. The client can maintain a cookie element that identifies the user so that the server can maintain things like shopping carts that are directly associated with the user and can easily be returned to at any time in the future.

    There are ways to maintain such information without client-side cookies, but they are cumbersome and usually need to be customized to the specific design of the Web site. It traditionally involves embedding some form of identification into the URL. There are many different ways to accomplish this, but the main problem is that every anchor on every page must be altered to reflect the session ID that needs to travel around with the user. This is precisely what the Cookie Munger that you mention does. (The Cookie Munger comes with the Microsoft Internet Information Server Resource Kit.) As you no doubt have determined, this can impose a heavy processing penalty onto every Web page.

    For sites that really need to deal with non-cookie-enabled browsers, testing the user coming into the site for support of cookies is the best way to handle this. If the browser supports it, then continue on to the normal site; if it doesn't, then switch the user over to a mirror copy of the site, but with the Cookie Munger installed. This way, only the cookieless users will be affected by the processing overhead.

GEEK I have the DirectX® 6.1 SDK, Visual Basic® 6.0 Professional, and Delphi 2 Developer. I cannot figure out how to use DirectX in either Visual Basic or Delphi. Do I need something else to use DirectX in either of those programming environments? Do you know where I can get sample source code for Visual Basic and Delphi?
GEEK DirectX 6.0 has some difficulties working with Visual Basic, primarily due to how Visual Basic deals with things such as callbacks, release order, and helper functions. In DirectX 7.0, many of these issues should be resolved to make it easier for you to use DirectX with Visual Basic. In the meantime, I've been told that http://www.chez.com/scribe contains some useful information on how to use DirectX with Visual Basic via a TLB file, but there will still be some areas of DirectX that you won't be able to deal with.

    I'm not sure about Delphi support. You should check with Inprise about that.

GEEK In the May 1999 issue of MIND, Paul Yao wrote that browsers running on Windows® CE don't support databinding, which allows client-side queries to server-side databases. Does this mean that devices using Windows CE and a browser won't be able to use a search engine?
GEEK No. Search engines can work fine with the Pocket Internet Explorer browser under Windows CE.

    Databinding is a feature of Microsoft Internet Explorer that allows database resultsets to be bound (hence the term "databinding") to a table or other HTML elements on a page. This allows the server to return a large table of data, but on the client this data is filtered and sorted before being displayed. a benefit of this is that if the user wants to resort or refilter the data based on different criteria, it can be done as a client-side operation without needing to do a round-trip to the server to get the new data.

    Databinding was first introduced with Internet Explorer 4.0, and tremendous optimization enhancements have been made to this feature in Internet Explorer 5.0.

GEEK I need to print reports from the browser and I'm trying to find out what my options are for controlling the formatting. Any suggestions for where I should concentrate my efforts? The client is Netscape Navigator 4.5.
GEEK Since you indicate that the client will be Netscape Navigator 4.5, I'm going to assume that what you really want to do is simply expose a button or a link on your page that, when clicked, will send a printout of the current page to the printer.

    The current versions of both Netscape Navigator and Internet Explorer now support the print method, so you can use code similar to


 <a href="javascript:window.print()">Print This Page</a>
to bring up the browser's print dialog and send the current page to the printer.

    But maybe you want to produce a different page for printing than you do for displaying within the Web browser. The Cascading Style Sheet (CSS) support in Internet Explorer allows you to specify styles specifically for printing. So if all of your changes can be defined as CSS styles, then all you need to do is use this code:


 <style media="print" type="text/css">
 •••
 </style>
The styles defined in this section will only be applied to the printed version of your pages—as opposed to the screen version of your pages. And since both the print and display styles can be included on the same Web page, all of this happens on the client, without the need for pulling down a new page from the server.

GEEK How can I print something like a ticket or a page on the client's printer using Active Server Pages (ASP)?
GEEK It is important to remember that ASP is a server-side technology that builds the page up before it is sent down the wire to the browser client. Once the page is being viewed by the browser, there is no connection to the ASP functionality of the page. Trying to print a ticket or a page on the client's printer using ASP is sort of like the author of a book trying to control the volume on the reader's stereo. It's not going to happen.

    Here's another thing to remember: anything that allowed you to generate a printout with no user interaction would be considered a security break and cannot be allowed from script code running on a Web page.

    That said, see my response to the previous question for ideas on printing your page.

GEEK I have some reports that currently exist in Microsoft Access and that need to be available to a client. Unfortunately, their workgroup doesn't have a unified desktop—there are different OSs and applications, so using Microsoft Access isn't going to work. The client needs to be able to run and print the reports locally. Is there any way to control the printing format, such as page breaks?
GEEK It sounds like you need the ability to add some additional formatting when your page is printed—as opposed to when it is being displayed.

    Fortunately, starting with Internet Explorer 4.0, you can achieve this using Cascading Style Sheets. It allows you to make some style definitions that apply to either the display or print versions of your page. This is done by using code like the following:


 <style>
 •••
 insert all your normal page style things here
 •••
 </style>
 
 <style media="print">
 •••
 insert the styles you want to apply only to the "print" version here
 •••
 </style>
You can use <style media="screen"> in the first case so that you have totally different (instead of overlapping) styles for the screen and printer.

    In your particular case, you want to force a page break. Here is how you would do that:


 <HTML>
 <HEAD>
 <STYLE>
 .pagebreak {page-break-before:always}
 </STYLE>
 </HEAD>
Note that in this case you don't need to invoke the media="print" attribute since page breaks have no screen representation. You then insert a page break into your page like this:

 <div class="pagebreak">&nbsp;</div>

GEEK Is there a way to script an HTML link to perform the same action as selecting Save Target As? I have an ASP page that has a Microsoft Excel MIME type. It reads recordset data and produces a table. When a user clicks on the link, the browser spawns Microsoft Excel and loads the spreadsheet with the recordset data. I want the user to be able to directly download the file instead of having it open in the browser first. For example, I right-click on the link, the file can then be saved directly to the client machine.
GEEK The issue here is that the data you are transferring is of a known MIME type, and a registered viewer is associated with it. The correct process is for the browser to bring up that application to view the document.

    Allowing the clicking of a link to silently download a file is a security risk, as I am sure you can understand. And while I'm sure you would be perfectly fine (and perhaps prefer) having a dialog come up telling the user they are downloading a file, and allow the user to specify the location, there isn't any way to do this that I know of right now.

GEEK Do you know of a way in SQL Server to query for rows whose startdate and enddate is a range in which a user-defined value is a member?

    I have an events table with startdate and enddate. Let's say a given event starts on 5/1/1999 and ends on 10/5/1999. Say the user has selected the day 7/20/1999. Since 7/20/1999 is within the date range 5/1/1999 to 10/5/1999, the event row should be returned, but my simple query doesn't catch it.

    I was thinking it might work if I could convert all dates to an integer value, maybe the number of days since 1998. (Doesn't Microsoft Access do something like this for the internal storage of dates?) Then I could just use the comparison


 ((userdate >= startdate) and (userdate <= enddate))
Is there such a conversion function in SQL Server? Does it even make sense to do it this way?
GEEK I needed something similar for a page I was creating that would report on news items that users had added to the database. The idea was that the user could specify a start date and strike date for the news item, and as long as the current date was within that span, the news item would show up on the page.

    Here is the SQL statement that I used:


 SQL = "SELECT * FROM News WHERE StartDate <= " & SQLDate(Now())
       & " and EndDate >= " & SQLDate(Now())
Note that I am using the VBScript Now function to get the current date.

    Then I pass this date into a simple function that converts this value into what SQL expects for a date value. Not immediately seeing any documentation that described this format, I used a little trial and error and found that the following is the proper algorithm:


 function SQLDate (date)
     SQLDate = DateDiff ("d", DateValue("1-Jan-1900"), DateValue(date))+2
 end function
So assuming you are using ASP, you can just insert this code into the appropriate places on your page and it will do the right tests for you.

GEEK After reinstalling Visual Basic 5.0, I get the following error when I try to use Toolbar and other custom controls: "License information for this component not found." Now, I'm sure that I have licensed the ActiveX® control. What should I do?
GEEK Check out the following Knowledge Base articles that talk about this situation:
http://support.microsoft.com/support/kb/articles/q177/7/99.asp
http://support.microsoft.com/support/kb/articles/Q181/8/54.asp
The issue you're talking about has to do with a Visual Basic 5.0-specific problem in resetting the license information for controls that are reinstalled. Here is a link to the vbc.exe application that is referenced in the previously mentioned Knowledge Base articles:
http://msdn.microsoft.com/vbasic/downloads/download.asp?ID=078.


From the July 1999 issue of Microsoft Internet Developer.