It shows that you are unregistered. Please register with us by clicking Here
![]() |
|
![]() |
![]() | Register - FAQ - Today's Posts - New Posts - Support - Search | ![]() |
|
|
#1 (permalink) |
|
Junior Member
Join Date: Jul 2006
Age: 40
Posts: 27
|
Hey all,
We're having some trouble here that 4 web developers haven't been able to solve. Hopefully a few more minds will be able to. Here are the players: A classic ASP page A database call and An include file Here's the problem. If we call the include file (using any method -- we've tried <% %>, response.writefile, response.write, server.execute...), it operates just fine. However, the second we put that include file into an if/then statement based on the results of the database query, it breaks. The static HTML code will parse, but none of the ASP *or* Javascript *or* vbscript on the included file will parse. What we want is for this pseudocode to operate: run database query If query.name = "bob" then - include file else - include other file end if The "magic code" in the include file is nothing more than a javascript countdown (or an ASP countdown or a vbscript countdown, none work) Any help would be greatly appreciated!! thanks cameron |
|
|
|
|
|
|
|
#2 (permalink) |
|
Junior Member
Join Date: Aug 2007
Posts: 2
|
I do not think you can run includes based on an IF statement, as I have been having similar problems (although my query is not based on results from a database call). I may be wrong, but is it running both includes? I think that it does the including prior to running the full page's ASP. Therefore maybe your includes are fighting with each other or something? I may be wrong though!
|
|
|
|
|
|
#3 (permalink) |
|
Junior Member
Join Date: Aug 2007
Posts: 2
|
Quick update through a bit of googling:
The ASP parser includes a file before executing any script commands. This means you can't put a variable in the filename and include files dynamically based on that variable's value. You can, however, load the include into a SUB and call the SUB only if certain criteria are met. For instance: <% IF foo = "bar" THEN %> <!--#include file ="include/bar.inc"--> <% ELSE %> <!--#include file ="include/foo.inc"--> <% END IF %> Will still load both include files into the ASP script, as opposed to only loading one of them. However, a cleaner way to do this might be: <% IF foo = "bar" THEN BAR ELSE FOO END IF %> <% SUB FOO %> <!--#include file ="include/foo.inc"--> <% END SUB %> <% SUB BAR %> <!--#include file ="include/bar.inc"--> <% END SUB %> |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What does a server-side include do? | agaba175 | ASP | 0 | 08-05-2006 07:36 PM |
| Update statement | peyton | ASP | 2 | 07-13-2006 02:32 PM |
| What would include in a small business tool kit | cameron | General Business Issues | 1 | 07-05-2006 08:48 PM |