Printer Friendly

 Email This
<% 'Pass the name of the file to the function. Function getFileContents(strIncludeFile) Dim objFSO Dim objText Dim strPage 'Instantiate the FileSystemObject Object. Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 'Open the file and pass it to a TextStream Object (objText). The '"MapPath" function of the Server Object is used to get the 'physical path for the file. Set objText = objFSO.OpenTextFile(Server.MapPath(strIncludeFile)) 'Read and return the contents of the file as a string. getFileContents = objText.ReadAll objText.Close Set objText = Nothing Set objFSO = Nothing End Function %> <% Dim strInclude 'Request.form("page") If Request.QueryString("page") = "" Then strInclude = getFileContents("home.htm") Else strInclude = getFileContents(Request.QueryString("page") & ".htm") End If Response.Write strInclude %>