"Conditional" file includes

Results 1 to 3 of 3

Thread: "Conditional" file includes

  1. #1
    Bill Anthony Guest

    Default "Conditional" file includes

    Greetings. I have a simple question regarding the use of conditional file includes. What I am attempting to do is display a web based chart that returns statistical information based on a user selection from the previous screen. <BR><BR>The "Request.Form" value is passed via "POST" method to the chart results ASP and during the processing of the results page, the type of chart displayed is dependent upon the value being passed. What I thought would be good programming would be to keep code pertaining to one type of chart separate from another in file includes. Let&#039s say they are "chart01.inc" and "chart02.inc". Based on the value being passed from the previous from, I was hoping to load either of the include files to render the desired chart.<BR><BR><BR>My code looks like this:<BR><BR>&#060;% If Request.Form("querylist") = "chart01" Then &#037;&#062;<BR>&#060;!--#include file=chart01.inc --><BR>&#060;% ElseIf Request.Form("querylist") = "chart02" Then &#037;&#062;<BR>&#060;!--#include file=chart02.inc --><BR>&#060;% End If &#037;&#062;<BR><BR>I also have separate includes arranged in the same fashion that perform ADO record counts against an Access database. These record counts will essentially get the statistics and the previous chart example is supposed to display them in chart format based on user selection.<BR><BR>I am not receiving any error messages and the ADO seems to run fine, but the chart display only seems to work in one format; not the other.<BR><BR>My question is: Why would the include method I am using work to process ADO code and not work when trying to display one chart over the other? Also, is there such a thing as "conditional file includes"? Finally, is there an easier method to do this?<BR><BR>Please help if you can - I would certainly appreciate anyone&#039s expertise.<BR><BR>Thank you.

  2. #2
    Dan Shawkey Guest

    Default RE: Conditional File Includes

    All includes are processed before server-side code is processed. There are a couple of different ways to do what you want. I don&#039t know what you have in your included files, so it is kind of difficult to recommend anything. One way I have found works very well is to use frames. I know many are against frames in any way, but you could process your code in the frameset page and display the charts conditionally in the frame. Another way would be to do a conditional redirect to another page. Hope this helps.<BR><BR>Dan

  3. #3
    Ian Stallings Guest

    Default RE:This is possible

    here is the code for using conditional<BR>includes:<BR>put this at the top:<BR>&#060;% response.buffer = true &#037;&#062;<BR><BR>&#060;%<BR>File = request.querystring("file")<BR>IncludeFile = server.mapPath("dynamic.inc")<BR>Set fs=Server.CreateObject("Scripting.FileSystemObject ")<BR>IF fs.FileExists(IncludeFile) THEN<BR>set f = fs.openTextFile(IncludeFile)<BR>content = f.readall<BR>set f = nothing <BR>set fs = nothing <BR>response.write(content)<BR><BR>End if<BR><BR>&#037;&#062;<BR><BR><BR>i hope this helps

Posting Permissions

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