Jeff Brown
Rafael M. Muņoz
Microsoft Corporation
July 6, 1998
Updated: December 15, 1998
The following article was originally published in the Site Builder Magazine (now known as MSDN Online Voices) "Web Men Talking" column.
Contents
Honey, I shrunk what? - Creating Mobile Channels
Connection off-kilter - Problems with ADO connections
Is it real, or is it ...? - Creating and using virtual directories
Sticking with selections - Changing <SELECT> tags dynamically
Input not required - Changing background color of form fields
Coding for a bright future - Referencing page elements using DHTML
Wow. As we review this month's collection of questions, we have to stop and think. Everything is connected. That's what the Internet, the Web, is all ... Hold it! We could become way too metaphysical here, what with all this talk of Mobile Channels and virtual directories. And just as our notion of physical space changes, we dive into the realms of interactivity: forms, selections, and database connectivity. The possibilities extend all the way to August, and beyond. So, enjoy this month's questions and answers -- while we return to contemplating the vastness of bandwidth.
Dear Web Men:
I am trying to build a Mobile Channel for my Palm PC device. Anyway, seems like there is a different CDF (Channel Definition Format) for mobile channels than for regular channels. I have tried making regular channels but they can't be AutoSync'd; the only one I can get working is the MSNBC mobile channel, which has some stuff like the following in the .cdf file:
<USAGE VALUE="MobileChannel"/>
Do I need stuff like this to make my own Mobile Channel?
Gracias mucho,
Joshua
The Web Men reply:
First came regular channels. Now we have tinier channels, or Mobile Channels . Looks like you are ready to head into new territory, Joshua. Remember, tread softly and carry a tiny browser. The new value for the USAGE tag that you point out above is just the beginning.
A quick and great starting point for Mobile Channels would be our buddy, Robert Hess, author of the column More or Hess. He will give you a quick over view of what's to come in Channels: A New Spin of the Dial.
The best reference for what's new for Mobile Channels is the Microsoft Developer Network Library Online . There you will find information on the new attributes and attribute values, along with sample files the come in very handy.
A quick overview from your Web pals: When creating Mobile Channels, remember that all Windows CE-based devices currently have a limited HTML control, and do not support frames or Dynamic HTML (DHTML). Space is a valued commodity with Palm-size PCs, and so the new CDF tags help to improve performance and reduce storage space on these devices. Refer to Mobile Channels Extensions to CDF for more information. Mobile Channels can be composed of either standard HTML pages; the more complex method is to create small data segments or files - script files (.mcs) , data files (.mcd) . Be sure to read the documentation thoroughly. Internet Explorer 4.0 ignores some of the new CDF elements used for Mobile Channels, while the Mobile Channel parser ignores some of the current elements used in today's CDF file.
One more place to inquire about Mobile Channels is the Internet Explorer 4.0 Channels newsgroup.
Good luck, Joshua, and we hope to see you out there on the mobile highway.
Dear Web Men:
We are an educational site that would like to make ASP files for our Web site so we can access databases and create active content. However, whenever we try to establish a connection with the database, we receive this error. We read through any help articles we could find on your site, but none of the suggestions seemed to work. We would appreciate any help that you can provide.
Server object error 'ASP 0177 : 800401f3' Server.CreateObject Failed /Calendar/tblEvents.asp, line 16 Invalid class string
Ernest Dotson
The Web Men reply:
As the error message indicates, there seems to be a problem with the string you are passing to the CreateObject method. The string you pass to the method is the class name or ProgID (programmatic identifier) of the COM object you want to create. Whatever you are passing in the string is not a COM object that Active Server Pages (ASP) technology recognizes.
To access databases with ASP, you use ActiveX Data Objects (ADO). With ADO, you can create a connection to a database using a Connection object. The following ASP script shows how to create a Connection object:
<% objConn = Server.CreateObject("ADODB.Connection") %>
Once you create the Connection object, you use its Open method to create the connection the database.
Working with databases is described in the ASP tutorial included in the Internet Information Server (IIS) 4.0 documentation. Check out Lesson 3: Using the Database Access Component of Module 2: Using ActiveX Components. For more code examples, take a look at the Database Connectivity section in Developer Samples.
If you continue to run into problems, and you're sure your ASP script is correct, and your database is set up properly, you could run the Windows NT Option Pack setup program again, and reinstall the Microsoft Data Access Components.
Dear Web Men:
I am looking for a way to do the following: My main drive with all my HTML files is C:\; however, I have pictures on drive D:\.
I have been trying on my own different things to link an HTML file from C:\ to another HTML file on D:\ -- in turn, linking to my pictures, but with no success. I find it is strange, as I can view my pictures in that fashion if I log onto my Web site locally, but nobody else can remotely.
Any ideas pleeesssseee.........
Dave Carr
The Web Men reply:
Dave, virtual worlds are of age, and with virtual worlds comes the idea of virtual directories. Okay, maybe the virtual directories came about another way, but they are exactly what you want to look at to achieve your goal.
A virtual directory is a directory that appears to be in your root directory, yet can reside somewhere else on your hard drive, or could even exist on another hard drive on your server. Yeah, we saw your eyebrow raise toward the end of that last sentence. For instructions on how to create a virtual directory, consult your operating system's manuals.
For our purposes, we will refer to Internet Information Server . With IIS, you get the Microsoft Management Console, which has HTML versions for those remote situations. If you already have IIS installed, just follow the directions below for creating a virtual directory. Otherwise, check out the Microsoft Windows NT 4.0 Option Pack for more information and download instructions.
For those of you asking yourselves, "Is there anything for Windows 95 , er 98 , or the Windows NT Workstation ?" The answer is yes. The solution is included with the Windows NT 4.0 Option Pack, and is referred to as the Personal Web Server .
To create a virtual directory:
Dear Web Men:
We have a number of applications using ASP technology to pull data from our SQL Server and Access databases. Is it possible to have dynamically changing selection boxes? So, if I select a category from a categories box, then the product list would change to show those products that relate to that category. With Internet Explorer 3.0, I did not think this was possible due to the lack of DHTML. Would I use DHTML to do this in Internet Explorer 4.01, along with RDS technology?
Due to a number of visually impaired users that utilize these Web sites, ActiveX technology/controls would not be a desirable approach. I would like to stick with SELECT type selection boxes if possible.
Any ideas?
Jeff
The Web Men reply:
Dynamically changing the options in a selection box (a.k.a., a list box) is easy to do with DHTML. There are ways you can get this effect without using DHTML, though. However, it would require you to send back a completely new page from the Web server.
Using DHTML and Remote Data Service (RDS) is a good idea. DHTML will enable you to change the options in existing selection boxes on the page, or even to add or remove selection boxes without needing to request a new page from the Web server. RDS gives you client-side caching and access to database records without having to navigate off the current page.
In a nutshell, what you could do is get the options collection for the SELECT, remove the existing options, and add new ones. But it probably would be easier just to recreate all the options for the SELECT at once by setting the innerHTML property of the SELECT.
Before you start hand-coding a lot of this in your favorite Web development tool, we recommend that you check out Microsoft Visual InterDev 6.0 .
Visual InterDev 6.0 allows you to build an application of this sort easily. It supports data-bound controls that can be targeted for client or server-based database access. With client-based database access, Visual InterDev 6.0 generates the script to integrate RDS into your page. You can more easily deal with recordsets from you database using the Recordset control. It also has several new scripting tools, including the Script Outline window, and Intellisense, that make it easy to do DHTML programming.
For more information about DHTML, see the MSDN Online Web Workshop. For more information about RDS, see the Microsoft Universal Data Access Web site .
Dear Web Men:
I hope you have an answer for me.
I need to gray-out an input box (field), but I don't think there is any way of doing this. I can't think of any way. I am doing this for non-required fields in a registration page.
Do you guys have any ideas?
Help!!!!!
Oscar
The Web Men reply:
Oscar, it seems that as the Internet grows and more resources become available for information, we are seeing more and more registration pages. At the Microsoft site alone, we have registration forms for Support Online , the Microsoft Developer Network , and our very own MSDN Online, to name just a few. You can imagine how many other forms must exist throughout the Web worldwide.
We thought your idea offered another great visual effect. Lots of sites use some kind of graphic to identify necessary fields, but usually nothing where input is not required. We know from experience that once into a registration form, we sometimes forget to identify the non-required fields -- and end up filling out the whole form. While this is probably great for the requesting party, what could have taken us two minutes ends up taking 10.
The effect you want to see can be achieved through the use of Cascading Style Sheets. With styles, you can change the background color by creating either an overall style for the entire form identifying all non-required fields, or you can use an inline script. Below, we show you the code for an inline script:
<INPUT TYPE=text VALUE="" NAME="textbox" SIZE=15 STYLE="background-color:gray">
So from this you now have .
For more information on DHTML, HTML or Cascading Style Sheets, be sure to check out the DHTML, HTML & CSS section of the MSDN Online Web Workshop.
Dear Web Men:
I hopefully have an easy one. When accessing the properties of elements using scripting, in Internet Explorer 4.0 or greater, the document.all["id"] command works quite well. I would like to know how to access only the tags? For example, if you are writing some script for a pop-up menu, and you want the menu of choice to turn on and the others to turn off, you could screen the DIV tags to see which ones are hidden or shown. As the object model is documented now, the only way to access either DIV or other area-defining tags is through the above-mentioned line of code. Is this true? Please help ... my coding future depends on it.
Chris S. Eddleman, MSDN Online Level 2 Member
The Web Men reply:
Well, this isn't too much of a stumper, Chris. However, that part about your coding future depending on it makes us a little jumpy (yikes!).
First, when writing your DHTML script, remember that if you already know the ID of an element, you can access it directly without having to use the all collection. You really only need to use the all collection if you won't know the ID of the element until run time.
Also, in addition to the entire document having an all collection, each element within the document has an all collection of its very own. An element's all collection is made up of just the elements it encloses (contains). To filter out all the tags of a particular type, use the tags method. It will build a collection of element objects that represent the tag you specify.
For all the goods on DHTML, see the MSDN Online Web Workshop.
Jeff Brown, when not forcing family and friends to listen to Zydeco and country blues music, helps develop training courses in the Microsoft Mastering Series -- with a smile.
Rafael M. Munoz is a part-time Adonis, and full-time support engineer for Microsoft Technical Support. He takes it very, very personally every time you flame Microsoft.
For in-depth training in Microsoft Web development tools and technologies, check out the Microsoft Mastering Series . Try out the award-winning Mastering Series online by browsing free sample chapters from Mastering Series training courses.
If you haven't found the answer, search the Knowledge Base (KB) on Microsoft Support Online . For a primer, see Jason Strayer's MSDN Online Voices feature, Knowledge Is Power: Inside the Microsoft KB.
Added July 20, 1998
Can't find an answer to your perplexing questions? Check the Web Men's Greatest Hits. We have done over 20 samples and have answered more than 180 questions; maybe yours has already been answered!
Q: Brian Shoemaker wants to detect the operating system of the user and return customized pages.
A: See Michael Edwards's article, Sniffing For Browsers, Java Virtual Machines, and Operating Systems.
Q: Nikunj Sanghvi wants to know if Internet Explorer 4.0 supports the JavaScript function window.focus().
A: Refer to the Web Workshop's DHTML, HTML & CSS section for information on the Window object and Focus method.
Q: Elliott Randall wants to know if the DHTML text animation created by FrontPage 98 will work with Netscape.
A: No. The dynAnimation function does a browser check on loading the page to ensure the animated text is positioned correctly, but no animation is performed.
July 6, 1998
Q: Tom Dillon wants to know if you can send a specific font to a client browser from a server.
A: See our Express yourself answer.
Q: Oscar Song asks if Microsoft has certifications for HTML or Web design.
A: There are no certifications for HTML or Web design, but broader Internet and site-building certifications. See the Microsoft Certified Professional Web site .
Q: David wants to display tool tips for hypertext links.
A: Refer to the Title Attribute of the Anchor Element.
Q: Todd S. Jones asks how to update two or more frames at the same time in response to a user clicking on something in one frame.
A: Check out the frames sample in our Frame frenzy gone mad answer.