Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

include & querystrings

Status
Not open for further replies.

taval

Programmer
Jul 19, 2000
192
GB
I was wondering how would I use varibles in conjuction with include statement. I have tried the following where CustID is a variable, but it doesnt seem to work can someone help me out.
Thanks.

ie

<!-- #include file=&quot;customer.asp?id=&quot;&&quot;<%=CustID%>&quot; -->

 
This can't be done, as the include file is processed BEFORE any ASP code is evaluated.

IIS5 introduces the .execute method, which will do what you want. If you're still using IIS4, you're out of luck.
 
I hear there is a way of doing it, I have asp page that has already has the variable CustID, I just want it to be attached on to the include filename as a querystring. I think there is a response.write way of doing this. But I don't know how.

Grateful for any help.
Thanks.
 
Sorry, taval, as I explained, by the time the custid variable is evaluated, all server side includes have already been done. However, you can simulate an include by physically opening the file yourself. Try this:

Code:
<%
IncludeFile custid & &quot;.asp&quot;

Sub IncludeFile(filename) 
    dim fso 
    dim f 
    dim tempfile 
    set fso=server.createobject(&quot;Scripting.FileSystemObject&quot;) 
    tempfile = server.mapPath(filename) 
    set f = fso.openTextFile(tempfile) 
    Response.write f.readall() 
    f.close
    set f = nothing
    set fso = nothing 
end sub

%>
 
But then you cant call the functions :(

I need to do a similar thing but be able to process the ASPs --BB
 
You can declare the variable at the top of the asp page, calculate the value for the variable above the <include> tag
and then in the include file you can call the variable. This should be possible as long as the variable is declared and set above the include tag
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top