HOWTO: Modifying .alx File Objects from Active Server Pages

ID: Q157748


The information in this article applies to:


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:

  1. Using the ActiveX Control Pad, create a new HTML Layout (.alx).


  2. Add a label (Label1) and a text box (TextBox1) control to the layout file.


  3. Click on the text box, and type test in the text box.


  4. On the File click Save As.


  5. 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.


  6. Using the ActiveX Control Pad, create a new HTML document.


  7. On the Edit menu, click Insert HTML Layout.


  8. Type in the name layout1.asp in the file name text box.

    NOTE: This file does not show up in the list of files.


  9. 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.
  1. Save this file as "page1.htm".


  2. 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.


  3. 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")
       %>
     


  4. 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 %>">
     


  5. 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) %>">
     


  6. Save "layout.asp."


  7. 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/

Additional query words:


Keywords          : kbADO kbASP kbASPObj kbGrpASP 
Version           : winnt:
Platform          : winnt 
Issue type        : kbhowto 

Last Reviewed: May 26, 1999