The information in this article applies to:
- Microsoft Active Server Pages, version 1.0
SUMMARY
Internet Information Server (IIS) Active Server Pages (ASP) can be used to
modify information in an ActiveX Layout file (.alx). To do this, server
side scripting should be placed in the .alx file.
MORE INFORMATION
Active Server Pages are run when the URL is processed by IIS. At this time,
the controls in an .alx file have not been created in Internet Explorer
(IE). Because of this, it is impossible to change a control in an .alx file
from the HTTP document hosting the .alx file using server-side scripting.
To do this, place the server-side scripting code in the .alx file itself.
When IE calls for the .alx file, IIS processes the server-side script
before handing the .alx file back to IE. The key to making this all happen
is to rename the .alx file with an ASP extension.
NOTE: The following example assumes that the Adventure Works sample site is
installed and working. It draws data from the AdvWorks data source.
To see an example of how this all works, use the following steps:
- Using the ActiveX Control Pad, create a new HTML Layout (.alx).
- Add a label (Label1) and a text box (TextBox1) control to the layout
file.
- Click on the text box, and type "test" in the text box without the
quotes.
- On the File click Save As.
- Save the file as "layout1.asp" without the quotes. Note that this is NOT
the default extension of .alx. Make sure you save all files in this
example in the same directory. This directory should be a directory
published by IIS, such as wwwroot. Make sure that IIS has execute
privileges on this directory so that it can run the script. The root of
the wwwroot directory does not have execute permissions setup by
default.
- Using the ActiveX Control Pad, create a new HTML document.
- On the Edit menu, click Insert HTML Layout.
- Type in the name "layout1.asp" in the file name text box.
NOTE: This file does not show up in the list of files.
- An object tag similar to the following appears in your HTML document:
<OBJECT CLASSID="CLSID:812AE312-8B8E-11CF-93C8-00AA00C08FDF"
ID="layout1_alx" STYLE="LEFT:0;TOP:0">
<PARAM NAME="ALXPATH" REF VALUE="layout1.asp">
</OBJECT>
If the VALUE= contains a full path to the layout1.asp file, remove it so it
reads as above.
- Save this file as "page1.htm".
- Open the file layout1.asp in a text editor such as Notepad. You cannot
open this in the ActiveX Control Pad because it brings up the layout
editor.
- Add the following lines at the beginning of the file:
<%
Set Con = Server.CreateObject("ADODB.Connection")
Conn.Open "AdvWorks"
rs = Conn.Execute("SELECT * FROM products")
%>
- Replace the line for the label object that reads as follows:
<PARAM NAME="Caption" VALUE="label1">
With the following line:
<PARAM NAME="Caption" VALUE="<% Response.Write rs(1).Name %>">
- Replace the line for the text box object that reads as follows:
<PARAM NAME="Value" VALUE="test">
With the following line:
<PARAM NAME="Value" VALUE="<% Response.Write rs(1) %>">
- Save "layout.asp."
- Open Internet Explorer and view page1.htm.
WARNING: After adding server-side script to your .alx file, be careful
about editing the file in the ActiveX Control Pad. If you open the file in
the ActiveX Control Pad, it converts all <% and %> markers to <% and
%>, respectively. This breaks the server-side script. You need to reverse
all of these changes manually. Therefore, it is best to have your .alx file
completely designed before adding server-side script to the file.
REFERENCES
For the latest Knowledge Base articles and other support information on
Visual InterDev and Active Server Pages, see the following page on the
Microsoft Technical Support site:
http://support.microsoft.com/support/vinterdev/
Keywords : AXSFHTML AXSFVBS
Technology : kbInetDev
Version : 1.0
Platform : NT WINDOWS
Issue type : kbhowto