Microsoft KB Archive/224963

= Using Enhanced  Tags for Includes =

Article ID: 224963

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft Internet Information Services 5.0

-



This article was previously published under Q224963



SUMMARY
Microsoft Internet Information Services (IIS) version 5.0 adds many new Active Server Pages (ASP) capabilities. This article describes how to use the new  tag syntax to include ASP code in another page.



MORE INFORMATION
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Previous versions of IIS allowed an ASP page to include the contents of another file using code similar to the following: IIS 5.0 has extended the server-side  tag to include a new SRC attribute as an alternative method to include another page. The new syntax may then look similar to the following:  All code in the included page appears to the scripting engine as though it were between the  and  tags. Therefore, unlike the #include directive, your included page should consist of raw code only.

For example, consider the following #include statement:

This statement would need to include a page similar to the following: <% For X = 1 To 5 Response.Write " Howdy! " Next %> Now consider the following  statement:  This page would need to include a page similar to the following: For X = 1 To 5 Response.Write " Howdy! " Next The  example is treated by ASP as though the parent page contains the following syntax:  For X = 1 To 5 Response.Write " Howdy! " Next  Note: No actual code should placed between the  and </SCRIPT> tags in the parent page, as it will be ignored.

The SRC attribute can use either relative or virtual paths, as shown in the following table:

The following ASP code demonstrates how to use the new  syntax to mix server-side and client-side scripting. <ol> <li> Save the following ASP page as "ScriptTest.asp" to a Web folder with Script Access enabled: <%@LANGUAGE="VBSCRIPT"%> Enhanced SCRIPT Example Enhanced SCRIPT Example

<form method="GET" name="objForm" action="<%=Request.ServerVariables("URL")%>"> <input type="text" name="Message"> <input type="submit" value="Submit">

</SCRIPT>



</SCRIPT>

</li> <li> Save the following code as "Server.inc" to the same folder: Dim strMessage strMessage = Request.QueryString("Message") If strMessage <> "" Then Response.Write vbCrLf & "<script for=""window"" event=""onLoad"" language=""JavaScript"">" Response.Write vbCrLf & "objForm.Message.value = '" & strMessage & "';" Response.Write vbCrLf & "showMessage('" & strMessage & "');" Response.Write vbCrLf & " " End If </li> <li> Next, save the following code as "client.inc" to the same folder: function showMessage(strText) { alert(strText) } </li></ol>

Notes:
 * When you first browse "ScriptTest.asp," the form is displayed and the client-side function is not called.
 * When you submit text to the page, the server-side script outputs another client-side function that displays the submitted text in the form's input box and in a pop-up window.

Keywords: kbhowto KB224963

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.