Click to See Complete Forum and Search --> : Dynamic Includes and request.querystring


mattster
10-06-2006, 06:59 AM
I would like to do something like the following, so that i can get the date from the query string and then insert the include file that is named by date, for example 061003.inc (yymmdd.inc), but of course the following does not work:

<% Dim newsPage

newsPage= request.querystring("np")
if newsPage="" or isnull(newsPage) then
newsPage= 0
end if

%>

<!--#include file="includes/news/<%= newsPage %>.inc"-->

I have been trying to figure out how to use "getFileContents" but with no success.

Could someone please help me?

Thanks in advance!

Freeky
10-06-2006, 10:12 AM
Hi there... I had the same problem a while ago..

What I can tell you, is that the problem you having is because the include loads before any asp code... once all includes have loaded, then the asp runs.

you either gonna have to load the includes from in an if statement or with a select case or summin..

but i would wait for sum1 more experienced to respond

Freeky
10-06-2006, 10:16 AM
or you could try sumthing like this...

I used this method instead, because i didnt get the include thing resolved.

<%

Dim objFSO, startfile, Data, myfile
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Dim objTextStream

strFileName = "c:\webs\forbes\" & startfile1
Const fsoForReading = 1




If objFSO.FileExists(strFileName) Then
'The file exists, so open it and output its contents
Set objTextStream = objFSO.OpenTextFile ( strFileName , fsoForReading )
Data = objTextStream.ReadAll
objTextStream.Close
Set objTextStream = Nothing
Else
'The file did not exist
Response.Write strFileName & " was not found."
End If

'Clean up
Set objFSO = Nothing

'All General Links

myfile = Data

response.write myfile



%>