ASP Scripts - JavaScripts - Code Snippets

1. Include files dynamically
You should use FileSystemObject to achieve this.
<%
Dim objFS,otf
Set objFS = CreateObject("Scripting.FileSystemObject")
Set otf = objFS.OpenTextFile(server.mappath("/include/filename.asp"), 1, False)
response.write otf.readall
otf.Close
set fs=nothing
%>
Tip : You can not include files as follows.

<% If case=1 then%>

<!--include file="file1.asp"-->

else

<!--include file="file1.asp"-->

End if %>

Back to code snippet home...