Microsoft KB Archive/157748

{|
 * width="100%"|

-

The information in this article applies to:


 * Active Server Pages

-

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. On the File click Save As. Save the file as layout1.asp. 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.</li>  An object tag similar to the following appears in your HTML document: <pre class="CODESAMP">  <OBJECT CLASSID="CLSID:812AE312-8B8E-11CF-93C8-00AA00C08FDF" ID="layout1_alx" STYLE="LEFT:0;TOP:0"> <PARAM NAME="ALXPATH" REF VALUE="layout1.asp"> </OBJECT> </li></ol>

If the VALUE= contains a full path to the layout1.asp file, remove it so it reads as above. <ol> Save this file as "page1.htm".</li> 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.</li>  Add the following lines at the beginning of the file:

<pre class="CODESAMP">  <% Set Con = Server.CreateObject("ADODB.Connection") Conn.Open "AdvWorks" rs = Conn.Execute("SELECT * FROM products") %> </li>  Replace the line for the label object that reads as follows:

<pre class="CODESAMP">   <PARAM NAME="Caption" VALUE="label1"> With the following line: <pre class="CODESAMP">   <PARAM NAME="Caption" VALUE="<% Response.Write rs(1).Name %>"> </li>  Replace the line for the text box object that reads as follows:

<pre class="CODESAMP">      <PARAM NAME="Value" VALUE="test"> With the following line:

<pre class="CODESAMP">      <PARAM NAME="Value" VALUE="<% Response.Write rs(1) %>"> </li> Save "layout.asp."</li> Open Internet Explorer and view page1.htm.</li></ol>

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.