Include Files using a variable

Results 1 to 5 of 5

Thread: Include Files using a variable

  1. #1
    Brent Willman Guest

    Default Include Files using a variable

    I have an ASP page that needs to have dynamic information and post a regular html page that is already in the index server the code is:<BR>&#060;A HREF=UpDelListings.asp?Listing_ID=&#060;% = Session("Listing_ID")&#037;&#062;>Edit this listing&#060;/A><BR>&#060;!--#INCLUDE FILE="../Listings/&#060;% = Session("Listing_ID") &#037;&#062;" &#037;&#062;--><BR>This however doesn&#039t work it says it can&#039t find the page, because the include file will not allow for dynamic data. <BR><BR>ANY IDEAS????<BR>Please let me know<BR>Thanks

  2. #2
    Ian Stallings Guest

    Default RE: Include Files using a variable

    How about using this:<BR><BR>&#060;A HREF=UpDelListings.asp?Listing_ID=&#060;% = Session("Listing_ID")&#037;&#062;>Edit this listing&#060;/A><BR>&#060;%<BR>IncludeFile = Session("Listing_ID")<BR>&#039you can change the following to whatever<BR>IncludeFile = server.mapPath(IncludeFile) <BR>set fs = server.createobject(scripting.fileSystemObject) <BR>set f = fs.openTextFile(IncludeFile) <BR>content = f.readall<BR>set f = nothing <BR>set fs = nothing <BR>response.write(content) <BR>&#037;&#062;<BR><BR>hope this helps.<BR><BR>

  3. #3
    Brent Willman Guest

    Default RE: Include Files using a variable

    That helped thank you so much

  4. #4
    Ian Stallings Guest

    Default RE: Include Files using a variable

    excellent. your welcome.


  5. #5
    Olivier Travers Guest

    Default RE: Include Files using a variable

    You answer a question I was having too (i.e. how to script include files), but I&#039m not very proficient in ASPs/VBScript so I&#039m not sure I figured out the answer! Could you help the clueless newbie I am there? Specifically, am I correct to assume your code relies on sessions (through the server.createobject method)? I understand sessions rely on cookies so isn&#039t there a way to script file includes without cookies?<BR><BR>Or did I really understand nothing at all?<BR><BR>Thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •