GEEK I have a table in a Microsoft® Access database that contains a list of document names and their URLs. How can I enter a file name in a Web page, click a button, and have it retrieve the URL from the database and open the document? GEEK You are trying to do two things here, and it is usually best to resolve problems like this with a "divide and conquer" approach. First, you have keywords in your database that you want to allow the user to search against. This is a relatively straightforward problem. You could create a form on a page that allows the user to enter the word (or in your case the document name) they are looking for. It might look something like this: |
<form action="Listing.asp" method=get>
<table><tr><td>Document Name:</td><td>
<input type=text name="Document"></td></tr><tr><td></td><td>
<input type=submit value="Search"></td>
</tr></table>
</form>
Then, your file Listing.asp would have the normal code for opening up your database and for setting your SQL request. It might look something like this:
<%
Set Conn = Server.CreateObject("ADODB.Connection")
DB = Session("Document_DB_ConnectionString")
Conn.Open DBSQL = "SELECT * FROM Storage WHERE DocumentName LIKE
" & Document & "% ORDER BY DocumentName"
Set RS_item = Conn.Execute(SQL)
%>
This would result in a set of records containing the documents requested in the search criteria provided by the user.
<a href="<%=RS_item("URL")%>"><%=RS_item("DocumentName")%></a>
but most likely you'd lay this out in a table view.
GEEK I'd like to have several color schemes for a Web site that can change on their own daily or at random. Can you help?
GEEK Switching stylesheets as a Web page is loading is very easy to do. In fact, over a year ago I wrote an article that illustrated how simply changing the stylesheet of a page could affect its layout:
http://msdn.microsoft.com/workshop/author/css/linkedcss.asp
While I didn't specifically intend to show how to load a stylesheet programmatically, that is how I wrote the pages to perform this function. The code in Figure 1 appears within the <HEAD> of the page that does this. Note that this code allows the name of the stylesheet to be embedded within the URL (in the location.search parameter). However, if no stylesheet is specified, I select one randomly.
GEEK I'd like to use the bluish color RGB(102,153,204) as a background color on my Web page, but I don't know its hexadecimal equivalent. What language do I need to use to make this color appear?
GEEK Any color value on a Web page needs to be listed as either an RGB triplet in hexadecimal notation (such as "#6699CC") or as an X-11 Named Color (such as "Corn-FlowerBlue"). There aren't any built-in mechanisms that
allow you to supply the color value as a decimal-based
RGB triplet.
The easiest way to convert from those decimal values to a hexadecimal value is to use a calculator that can do the conversions for you. (The calculator application that comes with Windows® is very handy for this kind of thing.) In your case, the value you want is 6699CC.
I've written several articles about using color on Web pages. You can find more information about named color values at: http://msdn.microsoft.com/workshop/design/color/colorpick.asp
http://msdn.microsoft.com/workshop/design/color/colorname.asp I've also written an article on the Safety Palette, which explains how to prevent your GIF images from dithering in an ugly fashion on 256-color systems:
http://msdn.microsoft.com/workshop/design/color/safety.asp
You could also use stylesheets to accomplish the same effect. You can either define a standard stylesheet like this
<style type="text/css">
body
background-color: rgb(102,153,204)
}
</style>
or do it inline in the <BODY> tag, like this:
<body style="background-color: rgb(102, 153, 204)">
GEEK My agency is creating a global e-mall to host multiple online stores. We use Site Server Enterprise Edition to develop and host the mall stores. After a user enters a login ID and password, how can we use a session variable to transparently trace a user across Commerce Server stores? Currently, when a
user goes into a store, we lose their login
information.
GEEK If you use the standard in-memory Session object, you'll run into problems across servers or applications on the same server. Instead of relying on session variables for tracking the user, you will need to implement some method of keeping track of this state information outside the scope of the session.
You could do this by persisting the user's state information in a shared back-end database, as is done with Commerce Orderform (in Site Server 2.0) using DBStorage. You could also use this state setting to maintain a constant user that is preserved across user login sessions. When the user logs back into the site you would retrieve the userid from the shopper table using the ShopperManager (in Site Server 2.0), then use that to perform ADO queries to get the appropriate state flags.
Note that this method will be a little slower than using standard in-memory Session objects. If you would like to try having the best of both worlds, you could code your pages so that they rely mostly on the Session objects, but fall back to the ShopperManager when they need to reinstate the userid state data.
To do this, the SessionOnStart code in the global.asa would have to notice that there isn't a userid present so it doesn't query the database for any state data. Once the user registers, the userid is established within the local Session object and, besides being maintained within that session, it is also extended onto the URLs in use to navigate through the site. This way, when the user moves out of the scope of one session and into another, the new session won't have the local userid value in its memory. It will, however, be able to see that it is within the current URL, and after extracting it, will be able to reinstantiate all the state information from the database.
In most cases the local Session object will contain the appropriate state information. When it doesn't, then the userid is extracted from the URL, the state information is retrieved from the master database, and the local Session object is populated with this information. When the userid isn't available within the URL, the user is asked to log in.
GEEK I placed the Microsoft Flex Grid control on my Web page and filled it with information from listboxes on the same page. What is the best way to pass the information located in the grid to the server?
GEEK The most straightforward way to pass information back to a server from the browser is to use a <FORM> and simply submit the data. Since the data in the Microsoft Flex Grid control will not be incorporated into the submission data sent back with the form automatically, you need to script that capability yourself.
To do this, add several <input type="hidden" ...> items on your form, and then use a script to fill in the values with specific row/column entries from your grid control. You could do this during processing of the OnSubmit event, or you could fill in the hidden input values every time you modified a value in the grid control, thus keeping them up-to-date.
GEEK I recently completed an app that uses ADO and a server-side DLL, running on Internet Information Server (IIS) 3.0, to produce a master-detail report viewable in either Microsoft Internet Explorer or Netscape Navigator. I used the typical navigation buttons (written in HTML and ASP) to advance through the master records, with associated detail records being displayed in a tabular fashion. How can I bring multipage report-printing features to an app running on IIS 3.0 while remaining browser-independent?
GEEK If I understand your question correctly, you want the user to view an individual report record as a simple (browser-independent) Web page, but to have a more detailed printout generated when they click on the browser's Print button.
There are two issues here. From a standard Web client model, there isn't any way for the server to be alerted that the user has clicked on the Print button and to be able to switch in a totally different Web page. Also, Web pages are primarily designed to provide an onscreen display format. While improvements are being made that allow them to print better (both the browser doing a better job at printing and allowing the page author to supply special printing information), there isn't yet support for this across multiple browsers.
There are two approaches you can take to allow your users to access good information for both viewing and printing. First, your Web page can offer a Format for Printing link, which will request from the ASP server a view of the document that is specifically designed for printing out. This method is already used by a number of Web sites:
http://www.news.com
Second, you can utilize the advanced HTML 4.0 capability for associating stylesheet information with a specific media type (print or screen) to control the page layout appropriately. For example, if you are using DHTML to achieve an expandable/collapsible outline view on a page, some fancy use of Cascading Style Sheets (CSS) formatting lets you set all of the collapsed outline elements to be fully visible when printed out. The method for associating different stylesheets based on output media is:
|
As for password authorization, if you are utilizing the servers on system-level password authentication, you simply need to set the appropriate security attributes on the files. This will make the server prompt the user for a name and password. The downside of this is that user accounts need to be created and maintained at the system level.
If you'd rather maintain the Web access accounts within your database, then you could simply present a standard Web form that prompts the user for that information. When the form is submitted, you can utilize server-side code to verify the sign-on based on information within the database. How you choose to manage access once the user is verified is up to you. You could establish a client-side cookie, a server-side Session object, or simply maintain an authorization ticket within the URLs with which the user navigates through your site. To get an idea of how this last approach might look, go to http://www.amazon.com which uses this method for keeping track of customers as they browse through their Web site. Advanced server add-on products like Microsoft Site Server will also often supply this type of feature, which can be utilized on almost any Web site. More information can be found at: http://www.microsoft.com/siteserver
GEEK Is it possible to embed page breaks in HTML or client-side script that are recognizable by a printer on the client?
|
|
The page-break-after and page-break-before styles can be associated with the block-oriented page items (such as BLOCKQUOTE, BODY, CENTER, DD, DIR, DIV, DL, DT, FIELDSET, FORM, H1, H2, H3, H4, H5, H6, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, UL, and XMP). But there is no way to force a page break on earlier versions of Internet Explorer or Netscape Navigator.
GEEK If I build an application based on IIS or SQL Server and I want to market it without giving the clients my ASP code, is there a way to package the application as a server-side ActiveX® object? Is there somewhere I can start to do this?
GEEK I created a Submit button that utilizes a script within an <INPUT> tag on one button and another script within an <IMAGE> tag to carry out a mouseover effect. How can I get the form to submit if the user elects to press the Enter key?
|
|
will bubble the keyup event clear up to the document body and display the specified message if the Enter key was pressed. (Note that I'm trapping onkeyup here, not onkeydown). Instead of displaying a message, you could easily submit the form instead.
|