<% '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 %> <% '------------------------------------------------------------- 'The "getFileContents" function should be included at the top 'of the ASP file. '------------------------------------------------------------- 'Declare variables to hold the content of the main page and 'the include file. Dim strMain, strInclude, fileName, fileNameNoExt 'Get the contents of the main page and pass them to the "strMain" 'variable. strMain = getFileContents("master.htm") 'Test to see if the "cboFile" select box is being submitted. If so, 'load the requested include file. If not, load the default include. 'Request.form("page") If Request.QueryString("page") = "" Then fileName = "home.htm" fileNameNoExt = "home" Else fileName = Request.QueryString("page") & ".htm" fileNameNoExt = Request.QueryString("page") End If strInclude = getFileContents(fileName) 'After the proper include file contents are loaded ("strInclude"), 'then insert it into the main page ("strMain") using the "Replace" 'function. strMain = replace(strMain,"##PRINTER_FRIENDLY##","Printer Friendly") strMain = replace(strMain,"##INCLUDE FILE HERE##",strInclude) If (fileName = "/nccr.htm") Then If Request.QueryString("subpage") = "" Then fileName = "overview_highlight.htm" fileNameNoExt = "nccr" Else fileName = Request.QueryString("subpage") & ".htm" fileNameNoExt = Request.QueryString("subpage") End If strInclude = getFileContents(fileName) strMain = replace(strMain,"##PRINTER_FRIENDLY##","Printer Friendly") strMain = replace(strMain,"##INCLUDE FILE HERE##",strInclude) ElseIf (fileName = "/nccr2010.htm") Then If Request.QueryString("subpage") = "" Then fileName = "nccr2010_overview.htm" fileNameNoExt = "nccr2010" Else fileName = Request.QueryString("subpage") & ".htm" fileNameNoExt = Request.QueryString("subpage") End If strInclude = getFileContents(fileName) strMain = replace(strMain,"##PRINTER_FRIENDLY##","Printer Friendly") strMain = replace(strMain,"##INCLUDE FILE HERE##",strInclude) ElseIf (fileName = "/gcp_home.htm") Then If Request.QueryString("subpage") = "" Then fileName = "gcp_overview.htm" fileNameNoExt = "gcp_home" Else fileName = Request.QueryString("subpage") & ".htm" fileNameNoExt = Request.QueryString("subpage") End If strInclude = getFileContents(fileName) strMain = replace(strMain,"##PRINTER_FRIENDLY##","Printer Friendly") strMain = replace(strMain,"##INCLUDE FILE HERE##",strInclude) End If 'Use the "Response" Object to "Write" the completed page to the client. Response.Write strMain %>