Instead of including the file, you can server.Execute it (IIS5+)
<%
Dim MyFilename
MyFilename = Request.Form("Filename")
%>
<table>
<tr>
<td><%=MyFilename%></td>
<td><% Server.Execite MyFilename %></td>
</tr>
</table>
But, something that will give you a bit more flexibility would be to use the
File System Object.
(
http://msdn.microsoft.com/library/en-us/script56/html/FSOoriFileSystemObjec t.asp)
You can do something like:
<object runat="server" progid="Scripting.FileSystemObject"
id="oFSO"></object>
<%
MyFilename = Request.Form("MyFilename")
sFilepath = Server.MapPath(MyFilename)
If MyFilename <> "" Then
If oFSO.FileExists(sFilepath) Then
sContents = Server.HTMLEncode(oFSO.OpenTextFile(sFilepath, 1).ReadAll)
RESPONSE.WRITE SCONTENTS
End If
Else
sContents = "(File does not exist.)"
End If
%>
<table>
<tr>
<td><%=MyFilename%></td>
<td><%=sContents%></td>
</tr>
</table>
Ray at work
[quoted text, click to view] "owen" <spam@spam.com> wrote in message
news:uO1TEI6%23DHA.2180@TK2MSFTNGP09.phx.gbl...
>
> "Ray at <%=sLocation%> [MVP]" <Too many private support requests - Ask for
> it if needed> wrote in message
news:OzhYX#5#DHA.2180@TK2MSFTNGP09.phx.gbl...
> > <!-- #include file="file.txt" -->
> >
>
> But what if the filename isn't hardcoded. Eg. it comes from a database or
> is typed on the web page. (Or anything besides hardcoded in an #include
> statement!).
>
> My situation is that I have a database table of .txt filenames and
> descriptions. The filenames correspond to files on the webserver. I
have
> no problem getting my info from the database but how can I *dynamically*
> insert the content of a given filename on the page.
>
> For example,
>
> <%
> Dim MyFilename
> MyFilename=Request.Form("Filename")
> %>
>
> <table>
> <tr>
> <td><%=filename%></td>
> <td>
> <<< read and display 'MyFilename' content here >>>
> </td>
> </tr>
> </table>
>
>
> See what I mean? The filename is chosen interactively and therefore an
> #include statement wont work.
>
>
> Owen
>
>
>