theflyingminst
03-19-2008, 05:28 PM
Hi I am trying to pass a folder name as a variable with include file. I've tried both of these idears and they return errors.
<!--#include file="../" & Your_UserName & "/default.asp"-->
<!--#include file="../<% =Your_UserName %>/default.asp"-->
Anyone got any idea's on this one?
Thanks.
.. Oh, also I shoouuld mention that I tried it this way and it shows the html of the page not the page results:
<%
cboFile=Request.QueryString("cboFile")
If MID(Request.QueryString("cboFile"),1,1)="/" Then
cboFile=MID(cboFile,2,LEN(cboFile))
End If
'And the page that joins everything together is:
'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
'Get the contents of the main page and pass them to the "strMain"
'variable.
strMain = getFileContents("../" & Your_UserName & "/default.asp")
'Test to see if the "cboFile" select box is being submitted. If so,
'load the requested include file. If not, load the default include.
If Request.QueryString("cboFile") = "" Then
strInclude = getFileContents("maintemplate.asp")
Else
strInclude = getFileContents(cboFile)
End If
'After the proper include file contents are loaded ("strInclude"),
'then insert it into the main page ("strMain") using the "Replace"
'function.
strMain = replace(strMain,"<!-- INCLUDE FILE HERE -->",strInclude)
'Remove hyperlink formating inserted by Word
strMain = replace(strMain,"a:link, span.MsoHyperlink","")
strMain = replace(strMain,"{color:blue;", "")
strMain = replace(strMain,"text-decoration:underline;}", "")
strMain = replace(strMain,"a:visited, span.MsoHyperlinkFollowed", "")
'Use the "Response" Object to "Write" the completed page to the client.
Response.Write strMain
%>
<!--#include file="../" & Your_UserName & "/default.asp"-->
<!--#include file="../<% =Your_UserName %>/default.asp"-->
Anyone got any idea's on this one?
Thanks.
.. Oh, also I shoouuld mention that I tried it this way and it shows the html of the page not the page results:
<%
cboFile=Request.QueryString("cboFile")
If MID(Request.QueryString("cboFile"),1,1)="/" Then
cboFile=MID(cboFile,2,LEN(cboFile))
End If
'And the page that joins everything together is:
'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
'Get the contents of the main page and pass them to the "strMain"
'variable.
strMain = getFileContents("../" & Your_UserName & "/default.asp")
'Test to see if the "cboFile" select box is being submitted. If so,
'load the requested include file. If not, load the default include.
If Request.QueryString("cboFile") = "" Then
strInclude = getFileContents("maintemplate.asp")
Else
strInclude = getFileContents(cboFile)
End If
'After the proper include file contents are loaded ("strInclude"),
'then insert it into the main page ("strMain") using the "Replace"
'function.
strMain = replace(strMain,"<!-- INCLUDE FILE HERE -->",strInclude)
'Remove hyperlink formating inserted by Word
strMain = replace(strMain,"a:link, span.MsoHyperlink","")
strMain = replace(strMain,"{color:blue;", "")
strMain = replace(strMain,"text-decoration:underline;}", "")
strMain = replace(strMain,"a:visited, span.MsoHyperlinkFollowed", "")
'Use the "Response" Object to "Write" the completed page to the client.
Response.Write strMain
%>